From sabre at nondot.org Mon Aug 11 01:12:47 2008
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 11 Aug 2008 06:12:47 -0000
Subject: [llvm-commits] [llvm] r54630 - /llvm/trunk/utils/llvmdo
Message-ID: <200808110612.m7B6ClZ1006375@zion.cs.uiuc.edu>
Author: lattner
Date: Mon Aug 11 01:12:45 2008
New Revision: 54630
URL: http://llvm.org/viewvc/llvm-project?rev=54630&view=rev
Log:
remove obsolete files
Modified:
llvm/trunk/utils/llvmdo
Modified: llvm/trunk/utils/llvmdo
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvmdo?rev=54630&r1=54629&r2=54630&view=diff
==============================================================================
--- llvm/trunk/utils/llvmdo (original)
+++ llvm/trunk/utils/llvmdo Mon Aug 11 01:12:45 2008
@@ -168,13 +168,6 @@
-o -name *AST-Remove.ll \
-o -name llvmAsmParser.cpp \
-o -name llvmAsmParser.h \
- -o -name Lexer.cpp \
- -o -name FileLexer.cpp \
- -o -name FileParser.cpp \
- -o -name FileParser.h \
- -o -name StackerParser.h \
- -o -name StackerParser.cpp \
- -o -name ConfigLexer.cpp \
-o -name PPCPerfectShuffle.h \
"
From sabre at nondot.org Mon Aug 11 01:13:31 2008
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 11 Aug 2008 06:13:31 -0000
Subject: [llvm-commits] [llvm] r54631 - in /llvm/trunk/docs:
GettingStarted.html Stacker.html index.html
Message-ID: <200808110613.m7B6DVip006410@zion.cs.uiuc.edu>
Author: lattner
Date: Mon Aug 11 01:13:31 2008
New Revision: 54631
URL: http://llvm.org/viewvc/llvm-project?rev=54631&view=rev
Log:
the stacker doc is way out of date.
Removed:
llvm/trunk/docs/Stacker.html
Modified:
llvm/trunk/docs/GettingStarted.html
llvm/trunk/docs/index.html
Modified: llvm/trunk/docs/GettingStarted.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=54631&r1=54630&r2=54631&view=diff
==============================================================================
--- llvm/trunk/docs/GettingStarted.html (original)
+++ llvm/trunk/docs/GettingStarted.html Mon Aug 11 01:13:31 2008
@@ -1291,8 +1291,7 @@
This directory contains projects that are not strictly part of LLVM but are
shipped with LLVM. This is also the directory where you should create your own
LLVM-based projects. See llvm/projects/sample for an example of how
- to set up your own project. See llvm/projects/Stacker for a fully
- functional example of a compiler front end.
+ to set up your own project.
Removed: llvm/trunk/docs/Stacker.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Stacker.html?rev=54630&view=auto
==============================================================================
--- llvm/trunk/docs/Stacker.html (original)
+++ llvm/trunk/docs/Stacker.html (removed)
@@ -1,1428 +0,0 @@
-
-
-
- Stacker: An Example Of Using LLVM
-
-
-
-
-Stacker: An Example Of Using LLVM
-
-
- Abstract
- Introduction
- Lessons I Learned About LLVM
-
- Everything's a Value!
- Terminate Those Blocks!
- Concrete Blocks
- push_back Is Your Friend
- The Wily GetElementPtrInst
- Getting Linkage Types Right
- Constants Are Easier Than That!
-
- The Stacker Lexicon
-
- The Stack
- Punctuation
- Comments
- Literals
- Words
- Standard Style
- Built-Ins
-
- Prime: A Complete Example
- Internal Code Details
-
- The Directory Structure
- The Lexer
- The Parser
- The Compiler
- The Runtime
- Compiler Driver
- Test Programs
- Exercise
- Things Remaining To Be Done
-
-
-
-
-
-
-
-
-
This document is another way to learn about LLVM. Unlike the
-LLVM Reference Manual or
-LLVM Programmer's Manual , here we learn
-about LLVM through the experience of creating a simple programming language
-named Stacker. Stacker was invented specifically as a demonstration of
-LLVM. The emphasis in this document is not on describing the
-intricacies of LLVM itself but on how to use it to build your own
-compiler system.
-
-
-
-
-
Amongst other things, LLVM is a platform for compiler writers.
-Because of its exceptionally clean and small IR (intermediate
-representation), compiler writing with LLVM is much easier than with
-other system. As proof, I wrote the entire compiler (language definition,
-lexer, parser, code generator, etc.) in about four days !
-That's important to know because it shows how quickly you can get a new
-language running when using LLVM. Furthermore, this was the first
-language the author ever created using LLVM. The learning curve is
-included in that four days.
-
The language described here, Stacker, is Forth-like. Programs
-are simple collections of word definitions, and the only thing definitions
-can do is manipulate a stack or generate I/O. Stacker is not a "real"
-programming language; it's very simple. Although it is computationally
-complete, you wouldn't use it for your next big project. However,
-the fact that it is complete, it's simple, and it doesn't have
-a C-like syntax make it useful for demonstration purposes. It shows
-that LLVM could be applied to a wide variety of languages.
-
The basic notions behind stacker is very simple. There's a stack of
-integers (or character pointers) that the program manipulates. Pretty
-much the only thing the program can do is manipulate the stack and do
-some limited I/O operations. The language provides you with several
-built-in words that manipulate the stack in interesting ways. To get
-your feet wet, here's how you write the traditional "Hello, World"
-program in Stacker:
-
: hello_world "Hello, World!" >s DROP CR ;
-: MAIN hello_world ;
-
This has two "definitions" (Stacker manipulates words, not
-functions and words have definitions): MAIN and
-hello_world. The MAIN definition is standard; it
-tells Stacker where to start. Here, MAIN is defined to
-simply invoke the word hello_world. The
-hello_world definition tells stacker to push the
-"Hello, World!" string on to the stack, print it out
-(>s), pop it off the stack (DROP), and
-finally print a carriage return (CR). Although
-hello_world uses the stack, its net effect is null. Well
-written Stacker definitions have that characteristic.
-
Exercise for the reader: how could you make this a one line program?
-
-
-Lessons I Learned About LLVM
-
-
Stacker was written for two purposes:
-
- to get the author over the learning curve, and
- to provide a simple example of how to write a compiler using LLVM.
-
-
During the development of Stacker, many lessons about LLVM were
-learned. Those lessons are described in the following subsections.
-
-
-
-
-
Although I knew that LLVM uses a Single Static Assignment (SSA) format,
-it wasn't obvious to me how prevalent this idea was in LLVM until I really
-started using it. Reading the
-Programmer's Manual and Language Reference ,
-I noted that most of the important LLVM IR (Intermediate Representation) C++
-classes were derived from the Value class. The full power of that simple
-design only became fully understood once I started constructing executable
-expressions for Stacker.
-
-
This really makes your programming go faster. Think about compiling code
-for the following C/C++ expression: (a|b)*((x+1)/(y+1)). Assuming
-the values are on the stack in the order a, b, x, y, this could be
-expressed in stacker as: 1 + SWAP 1 + / ROT2 OR *.
-You could write a function using LLVM that computes this expression like
-this:
-
-
-Value*
-expression(BasicBlock* bb, Value* a, Value* b, Value* x, Value* y )
-{
- ConstantInt* one = ConstantInt::get(Type::IntTy, 1);
- BinaryOperator* or1 = BinaryOperator::createOr(a, b, "", bb);
- BinaryOperator* add1 = BinaryOperator::createAdd(x, one, "", bb);
- BinaryOperator* add2 = BinaryOperator::createAdd(y, one, "", bb);
- BinaryOperator* div1 = BinaryOperator::createDiv(add1, add2, "", bb);
- BinaryOperator* mult1 = BinaryOperator::createMul(or1, div1, "", bb);
- return mult1;
-}
-
-
-
"Okay, big deal," you say? It is a big deal. Here's why. Note that I didn't
-have to tell this function which kinds of Values are being passed in. They could be
-Instructions, Constants, GlobalVariables, or
-any of the other subclasses of Value that LLVM supports.
-Furthermore, if you specify Values that are incorrect for this sequence of
-operations, LLVM will either notice right away (at compilation time) or the LLVM
-Verifier will pick up the inconsistency when the compiler runs. In either case
-LLVM prevents you from making a type error that gets passed through to the
-generated program. This really helps you write a compiler that
-always generates correct code!
-
The second point is that we don't have to worry about branching, registers,
-stack variables, saving partial results, etc. The instructions we create
-are the values we use. Note that all that was created in the above
-code is a Constant value and five operators. Each of the instructions is
-the resulting value of that instruction. This saves a lot of time.
-
The lesson is this: SSA form is very powerful: there is no difference
-between a value and the instruction that created it. This is fully
-enforced by the LLVM IR. Use it to your best advantage.
-
-
-
-
-
I had to learn about terminating blocks the hard way: using the debugger
-to figure out what the LLVM verifier was trying to tell me and begging for
-help on the LLVMdev mailing list. I hope you avoid this experience.
-
Emblazon this rule in your mind:
-
- All BasicBlocks in your compiler must be
- terminated with a terminating instruction (branch, return, etc.).
-
-
-
Terminating instructions are a semantic requirement of the LLVM IR. There
-is no facility for implicitly chaining together blocks placed into a function
-in the order they occur. Indeed, in the general case, blocks will not be
-added to the function in the order of execution because of the recursive
-way compilers are written.
-
Furthermore, if you don't terminate your blocks, your compiler code will
-compile just fine. You won't find out about the problem until you're running
-the compiler and the module you just created fails on the LLVM Verifier.
-
-
-
-
-
After a little initial fumbling around, I quickly caught on to how blocks
-should be constructed. In general, here's what I learned:
-
- Create your blocks early. While writing your compiler, you
- will encounter several situations where you know apriori that you will
- need several blocks. For example, if-then-else, switch, while, and for
- statements in C/C++ all need multiple blocks for expression in LLVM.
- The rule is, create them early.
- Terminate your blocks early. This just reduces the chances
- that you forget to terminate your blocks which is required (go
- here for more).
- Use getTerminator() for instruction insertion. I noticed early on
- that many of the constructors for the Instruction classes take an optional
- insert_before argument. At first, I thought this was a mistake
- because clearly the normal mode of inserting instructions would be one at
- a time after some other instruction, not before . However,
- if you hold on to your terminating instruction (or use the handy dandy
- getTerminator() method on a BasicBlock), it can
- always be used as the insert_before argument to your instruction
- constructors. This causes the instruction to automatically be inserted in
- the RightPlace™ place, just before the terminating instruction. The
- nice thing about this design is that you can pass blocks around and insert
- new instructions into them without ever knowing what instructions came
- before. This makes for some very clean compiler design.
-
-
The foregoing is such an important principal, its worth making an idiom:
-
-BasicBlock* bb = BasicBlock::Create();
-bb->getInstList().push_back( BranchInst::Create( ... ) );
-new Instruction(..., bb->getTerminator() );
-
-
To make this clear, consider the typical if-then-else statement
-(see StackerCompiler::handle_if() method). We can set this up
-in a single function using LLVM in the following way:
-
-using namespace llvm;
-BasicBlock*
-MyCompiler::handle_if( BasicBlock* bb, ICmpInst* condition )
-{
- // Create the blocks to contain code in the structure of if/then/else
- BasicBlock* then_bb = BasicBlock::Create();
- BasicBlock* else_bb = BasicBlock::Create();
- BasicBlock* exit_bb = BasicBlock::Create();
-
- // Insert the branch instruction for the "if"
- bb->getInstList().push_back( BranchInst::Create( then_bb, else_bb, condition ) );
-
- // Set up the terminating instructions
- then->getInstList().push_back( BranchInst::Create( exit_bb ) );
- else->getInstList().push_back( BranchInst::Create( exit_bb ) );
-
- // Fill in the then part .. details excised for brevity
- this->fill_in( then_bb );
-
- // Fill in the else part .. details excised for brevity
- this->fill_in( else_bb );
-
- // Return a block to the caller that can be filled in with the code
- // that follows the if/then/else construct.
- return exit_bb;
-}
-
-
Presumably in the foregoing, the calls to the "fill_in" method would add
-the instructions for the "then" and "else" parts. They would use the third part
-of the idiom almost exclusively (inserting new instructions before the
-terminator). Furthermore, they could even recurse back to handle_if
-should they encounter another if/then/else statement, and it will just work.
-
Note how cleanly this all works out. In particular, the push_back methods on
-the BasicBlock's instruction list. These are lists of type
-Instruction (which is also of type Value). To create
-the "if" branch we merely instantiate a BranchInst that takes as
-arguments the blocks to branch to and the condition to branch on. The
-BasicBlock objects act like branch labels! This new
-BranchInst terminates the BasicBlock provided
-as an argument. To give the caller a way to keep inserting after calling
-handle_if, we create an exit_bb block which is
-returned
-to the caller. Note that the exit_bb block is used as the
-terminator for both the then_bb and the else_bb
-blocks. This guarantees that no matter what else handle_if
-or fill_in does, they end up at the exit_bb block.
-
-
-
-
-
-
-One of the first things I noticed is the frequent use of the "push_back"
-method on the various lists. This is so common that it is worth mentioning.
-The "push_back" inserts a value into an STL list, vector, array, etc. at the
-end. The method might have also been named "insert_tail" or "append".
-Although I've used STL quite frequently, my use of push_back wasn't very
-high in other programs. In LLVM, you'll use it all the time.
-
-
-
-The Wily GetElementPtrInst
-
-
-It took a little getting used to and several rounds of postings to the LLVM
-mailing list to wrap my head around this instruction correctly. Even though I had
-read the Language Reference and Programmer's Manual a couple times each, I still
-missed a few very key points:
-
-
-GetElementPtrInst gives you back a Value for the last thing indexed.
-All global variables in LLVM are pointers .
-Pointers must also be dereferenced with the GetElementPtrInst
-instruction.
-
-
This means that when you look up an element in the global variable (assuming
-it's a struct or array), you must deference the pointer first! For many
-things, this leads to the idiom:
-
-
-std::vector<Value*> index_vector;
-index_vector.push_back( ConstantInt::get( Type::LongTy, 0 );
-// ... push other indices ...
-GetElementPtrInst* gep = GetElementPtrInst::Create( ptr, index_vector );
-
-
For example, suppose we have a global variable whose type is [24 x int]. The
-variable itself represents a pointer to that array. To subscript the
-array, we need two indices, not just one. The first index (0) dereferences the
-pointer. The second index subscripts the array. If you're a "C" programmer, this
-will run against your grain because you'll naturally think of the global array
-variable and the address of its first element as the same. That tripped me up
-for a while until I realized that they really do differ .. by type .
-Remember that LLVM is strongly typed. Everything has a type.
-The "type" of the global variable is [24 x int]*. That is, it's
-a pointer to an array of 24 ints. When you dereference that global variable with
-a single (0) index, you now have a "[24 x int]" type. Although
-the pointer value of the dereferenced global and the address of the zero'th element
-in the array will be the same, they differ in their type. The zero'th element has
-type "int" while the pointer value has type "[24 x int]".
-
Get this one aspect of LLVM right in your head, and you'll save yourself
-a lot of compiler writing headaches down the road.
-
-
-Getting Linkage Types Right
-
-
Linkage types in LLVM can be a little confusing, especially if your compiler
-writing mind has affixed firm concepts to particular words like "weak",
-"external", "global", "linkonce", etc. LLVM does not use the precise
-definitions of, say, ELF or GCC, even though they share common terms. To be fair,
-the concepts are related and similar but not precisely the same. This can lead
-you to think you know what a linkage type represents but in fact it is slightly
-different. I recommend you read the
- Language Reference on this topic very
-carefully. Then, read it again.
-
Here are some handy tips that I discovered along the way:
-
- Uninitialized means external. That is, the symbol is declared in the current
- module and can be used by that module, but it is not defined by that module.
- Setting an initializer changes a global' linkage type. Setting an
- initializer changes a global's linkage type from whatever it was to a normal,
- defined global (not external). You'll need to call the setLinkage() method to
- reset it if you specify the initializer after the GlobalValue has been constructed.
- This is important for LinkOnce and Weak linkage types.
- Appending linkage can keep track of things. Appending linkage can
- be used to keep track of compilation information at runtime. It could be used,
- for example, to build a full table of all the C++ virtual tables or hold the
- C++ RTTI data, or whatever. Appending linkage can only be applied to arrays.
- All arrays with the same name in each module are concatenated together at link
- time.
-
-
-
-Constants Are Easier Than That!
-
-
-Constants in LLVM took a little getting used to until I discovered a few utility
-functions in the LLVM IR that make things easier. Here's what I learned:
-
- Constants are Values like anything else and can be operands of instructions
- Integer constants, frequently needed, can be created using the static "get"
- methods of the ConstantInt class. The nice thing about these is that you can
- "get" any kind of integer quickly.
- There's a special method on Constant class which allows you to get the null
- constant for any type. This is really handy for initializing large
- arrays or structures, etc.
-
-
-
-
-This section describes the Stacker language
-
-
-
Stacker definitions define what they do to the global stack. Before
-proceeding, a few words about the stack are in order. The stack is simply
-a global array of 32-bit integers or pointers. A global index keeps track
-of the location of the top of the stack. All of this is hidden from the
-programmer, but it needs to be noted because it is the foundation of the
-conceptual programming model for Stacker. When you write a definition,
-you are, essentially, saying how you want that definition to manipulate
-the global stack.
-
Manipulating the stack can be quite hazardous. There is no distinction
-given and no checking for the various types of values that can be placed
-on the stack. Automatic coercion between types is performed. In many
-cases, this is useful. For example, a boolean value placed on the stack
-can be interpreted as an integer with good results. However, using a
-word that interprets that boolean value as a pointer to a string to
-print out will almost always yield a crash. Stacker simply leaves it
-to the programmer to get it right without any interference or hindering
-on interpretation of the stack values. You've been warned. :)
-
-
-
-
-
Punctuation in Stacker is very simple. The colon and semi-colon
-characters are used to introduce and terminate a definition
-(respectively). Except for FORWARD declarations, definitions
-are all you can specify in Stacker. Definitions are read left to right.
-Immediately after the colon comes the name of the word being defined.
-The remaining words in the definition specify what the word does. The definition
-is terminated by a semi-colon.
-
So, your typical definition will have the form:
-
: name ... ;
-
The name is up to you but it must start with a letter and contain
-only letters, numbers, and underscore. Names are case sensitive and must not be
-the same as the name of a built-in word. The ... is replaced by
-the stack manipulating words that you wish to define name as.
-
-
-
-
-
Stacker supports two types of comments. A hash mark (#) starts a comment
- that extends to the end of the line. It is identical to the kind of comments
- commonly used in shell scripts. A pair of parentheses also surround a comment.
- In both cases, the content of the comment is ignored by the Stacker compiler. The
- following does nothing in Stacker.
-
-
-# This is a comment to end of line
-( This is an enclosed comment )
-
-
See the example program to see comments in use in
-a real program.
-
-
-
-
-
There are three kinds of literal values in Stacker: Integers, Strings,
- and Booleans. In each case, the stack operation is to simply push the
- value on to the stack. So, for example:
- 42 " is the answer." TRUE
- will push three values on to the stack: the integer 42, the
- string " is the answer.", and the boolean TRUE.
-
-
-
-
-
Each definition in Stacker is composed of a set of words. Words are
-read and executed in order from left to right. There is very little
-checking in Stacker to make sure you're doing the right thing with
-the stack. It is assumed that the programmer knows how the stack
-transformation he applies will affect the program.
-
Words in a definition come in two flavors: built-in and programmer
-defined. Simply mentioning the name of a previously defined or declared
-programmer-defined word causes that word's stack actions to be invoked. It
-is somewhat like a function call in other languages. The built-in
-words have various effects, described below .
-
Sometimes you need to call a word before it is defined. For this, you can
-use the FORWARD declaration. It looks like this:
-
FORWARD name ;
-
This simply states to Stacker that "name" is the name of a definition
-that is defined elsewhere. Generally it means the definition can be found
-"forward" in the file. But, it doesn't have to be in the current compilation
-unit. Anything declared with FORWARD is an external symbol for
-linking.
-
-
-
-
-
-
-
-
The built-in words of the Stacker language are put in several groups
-depending on what they do. The groups are as follows:
-
- Logical : These words provide the logical operations for
- comparing stack operands. The words are: < > <= >=
- = <> true false.
- Bitwise : These words perform bitwise computations on
- their operands. The words are: << >> XOR AND NOT
- Arithmetic : These words perform arithmetic computations on
- their operands. The words are: ABS NEG + - * / MOD */ ++ -- MIN MAX
- Stack These words manipulate the stack directly by moving
- its elements around. The words are: DROP DROP2 NIP NIP2 DUP DUP2
- SWAP SWAP2 OVER OVER2 ROT ROT2 RROT RROT2 TUCK TUCK2 PICK SELECT ROLL
- Memory These words allocate, free, and manipulate memory
- areas outside the stack. The words are: MALLOC FREE GET PUT
- Control : These words alter the normal left to right flow
- of execution. The words are: IF ELSE ENDIF WHILE END RETURN EXIT RECURSE
- I/O : These words perform output on the standard output
- and input on the standard input. No other I/O is possible in Stacker.
- The words are: SPACE TAB CR >s >d >c <s <d <c.
-
-
While you may be familiar with many of these operations from other
-programming languages, a careful review of their semantics is important
-for correct programming in Stacker. Of most importance is the effect
-that each of these built-in words has on the global stack. The effect is
-not always intuitive. To better describe the effects, we'll borrow from Forth the idiom of
-describing the effect on the stack with:
-
BEFORE -- AFTER
-
That is, to the left of the -- is a representation of the stack before
-the operation. To the right of the -- is a representation of the stack
-after the operation. In the table below that describes the operation of
-each of the built in words, we will denote the elements of the stack
-using the following construction:
-
- b - a boolean truth value
- w - a normal integer valued word.
- s - a pointer to a string value
- p - a pointer to a malloc'd memory block
-
-
-
-
-Definition Of Operation Of Built In Words
-LOGICAL OPERATIONS
-
- Word
- Name
- Operation
- Description
-
-
- <
- LT
- w1 w2 -- b
- Two values (w1 and w2) are popped off the stack and
- compared. If w1 is less than w2, TRUE is pushed back on
- the stack, otherwise FALSE is pushed back on the stack.
-
->
- GT
- w1 w2 -- b
- Two values (w1 and w2) are popped off the stack and
- compared. If w1 is greater than w2, TRUE is pushed back on
- the stack, otherwise FALSE is pushed back on the stack.
-
->=
- GE
- w1 w2 -- b
- Two values (w1 and w2) are popped off the stack and
- compared. If w1 is greater than or equal to w2, TRUE is
- pushed back on the stack, otherwise FALSE is pushed back
- on the stack.
-
-<=
- LE
- w1 w2 -- b
- Two values (w1 and w2) are popped off the stack and
- compared. If w1 is less than or equal to w2, TRUE is
- pushed back on the stack, otherwise FALSE is pushed back
- on the stack.
-
-=
- EQ
- w1 w2 -- b
- Two values (w1 and w2) are popped off the stack and
- compared. If w1 is equal to w2, TRUE is
- pushed back on the stack, otherwise FALSE is pushed back
-
-
-<>
- NE
- w1 w2 -- b
- Two values (w1 and w2) are popped off the stack and
- compared. If w1 is equal to w2, TRUE is
- pushed back on the stack, otherwise FALSE is pushed back
-
-
-FALSE
- FALSE
- -- b
- The boolean value FALSE (0) is pushed on to the stack.
-
-TRUE
- TRUE
- -- b
- The boolean value TRUE (-1) is pushed on to the stack.
-
-BITWISE OPERATORS
-
- Word
- Name
- Operation
- Description
-
-<<
- SHL
- w1 w2 -- w1<<w2
- Two values (w1 and w2) are popped off the stack. The w2
- operand is shifted left by the number of bits given by the
- w1 operand. The result is pushed back to the stack.
-
->>
- SHR
- w1 w2 -- w1>>w2
- Two values (w1 and w2) are popped off the stack. The w2
- operand is shifted right by the number of bits given by the
- w1 operand. The result is pushed back to the stack.
-
-OR
- OR
- w1 w2 -- w2|w1
- Two values (w1 and w2) are popped off the stack. The values
- are bitwise OR'd together and pushed back on the stack. This is
- not a logical OR. The sequence 1 2 OR yields 3 not 1.
-
-AND
- AND
- w1 w2 -- w2&w1
- Two values (w1 and w2) are popped off the stack. The values
- are bitwise AND'd together and pushed back on the stack. This is
- not a logical AND. The sequence 1 2 AND yields 0 not 1.
-
-XOR
- XOR
- w1 w2 -- w2^w1
- Two values (w1 and w2) are popped off the stack. The values
- are bitwise exclusive OR'd together and pushed back on the stack.
- For example, The sequence 1 3 XOR yields 2.
-
-ARITHMETIC OPERATORS
-
- Word
- Name
- Operation
- Description
-
-ABS
- ABS
- w -- |w|
- One value s popped off the stack; its absolute value is computed
- and then pushed on to the stack. If w1 is -1 then w2 is 1. If w1 is
- 1 then w2 is also 1.
-
-NEG
- NEG
- w -- -w
- One value is popped off the stack which is negated and then
- pushed back on to the stack. If w1 is -1 then w2 is 1. If w1 is
- 1 then w2 is -1.
-
- +
- ADD
- w1 w2 -- w2+w1
- Two values are popped off the stack. Their sum is pushed back
- on to the stack
-
- -
- SUB
- w1 w2 -- w2-w1
- Two values are popped off the stack. Their difference is pushed back
- on to the stack
-
- *
- MUL
- w1 w2 -- w2*w1
- Two values are popped off the stack. Their product is pushed back
- on to the stack
-
- /
- DIV
- w1 w2 -- w2/w1
- Two values are popped off the stack. Their quotient is pushed back
- on to the stack
-
-MOD
- MOD
- w1 w2 -- w2%w1
- Two values are popped off the stack. Their remainder after division
- of w1 by w2 is pushed back on to the stack
-
- */
- STAR_SLAH
- w1 w2 w3 -- (w3*w2)/w1
- Three values are popped off the stack. The product of w1 and w2 is
- divided by w3. The result is pushed back on to the stack.
-
- ++
- INCR
- w -- w+1
- One value is popped off the stack. It is incremented by one and then
- pushed back on to the stack.
-
- --
- DECR
- w -- w-1
- One value is popped off the stack. It is decremented by one and then
- pushed back on to the stack.
-
-MIN
- MIN
- w1 w2 -- (w2<w1?w2:w1)
- Two values are popped off the stack. The larger one is pushed back
- on to the stack.
-
-MAX
- MAX
- w1 w2 -- (w2>w1?w2:w1)
- Two values are popped off the stack. The larger value is pushed back
- on to the stack.
-
-STACK MANIPULATION OPERATORS
-
- Word
- Name
- Operation
- Description
-
-DROP
- DROP
- w --
- One value is popped off the stack.
-
-DROP2
- DROP2
- w1 w2 --
- Two values are popped off the stack.
-
-NIP
- NIP
- w1 w2 -- w2
- The second value on the stack is removed from the stack. That is,
- a value is popped off the stack and retained. Then a second value is
- popped and the retained value is pushed.
-
-NIP2
- NIP2
- w1 w2 w3 w4 -- w3 w4
- The third and fourth values on the stack are removed from it. That is,
- two values are popped and retained. Then two more values are popped and
- the two retained values are pushed back on.
-
-DUP
- DUP
- w1 -- w1 w1
- One value is popped off the stack. That value is then pushed on to
- the stack twice to duplicate the top stack vaue.
-
-DUP2
- DUP2
- w1 w2 -- w1 w2 w1 w2
- The top two values on the stack are duplicated. That is, two vaues
- are popped off the stack. They are alternately pushed back on the
- stack twice each.
-
-SWAP
- SWAP
- w1 w2 -- w2 w1
- The top two stack items are reversed in their order. That is, two
- values are popped off the stack and pushed back on to the stack in
- the opposite order they were popped.
-
-SWAP2
- SWAP2
- w1 w2 w3 w4 -- w3 w4 w2 w1
- The top four stack items are swapped in pairs. That is, two values
- are popped and retained. Then, two more values are popped and retained.
- The values are pushed back on to the stack in the reverse order but
- in pairs.
-
-OVER
- OVER
- w1 w2-- w1 w2 w1
- Two values are popped from the stack. They are pushed back
- on to the stack in the order w1 w2 w1. This seems to cause the
- top stack element to be duplicated "over" the next value.
-
-OVER2
- OVER2
- w1 w2 w3 w4 -- w1 w2 w3 w4 w1 w2
- The third and fourth values on the stack are replicated on to the
- top of the stack
-
-ROT
- ROT
- w1 w2 w3 -- w2 w3 w1
- The top three values are rotated. That is, three value are popped
- off the stack. They are pushed back on to the stack in the order
- w1 w3 w2.
-
-ROT2
- ROT2
- w1 w2 w3 w4 w5 w6 -- w3 w4 w5 w6 w1 w2
- Like ROT but the rotation is done using three pairs instead of
- three singles.
-
-RROT
- RROT
- w1 w2 w3 -- w3 w1 w2
- Reverse rotation. Like ROT, but it rotates the other way around.
- Essentially, the third element on the stack is moved to the top
- of the stack.
-
-RROT2
- RROT2
- w1 w2 w3 w4 w5 w6 -- w3 w4 w5 w6 w1 w2
- Double reverse rotation. Like RROT but the rotation is done using
- three pairs instead of three singles. The fifth and sixth stack
- elements are moved to the first and second positions
-
-TUCK
- TUCK
- w1 w2 -- w2 w1 w2
- Similar to OVER except that the second operand is being
- replicated. Essentially, the first operand is being "tucked"
- in between two instances of the second operand. Logically, two
- values are popped off the stack. They are placed back on the
- stack in the order w2 w1 w2.
-
-TUCK2
- TUCK2
- w1 w2 w3 w4 -- w3 w4 w1 w2 w3 w4
- Like TUCK but a pair of elements is tucked over two pairs.
- That is, the top two elements of the stack are duplicated and
- inserted into the stack at the fifth and positions.
-
-PICK
- PICK
- x0 ... Xn n -- x0 ... Xn x0
- The top of the stack is used as an index into the remainder of
- the stack. The element at the nth position replaces the index
- (top of stack). This is useful for cycling through a set of
- values. Note that indexing is zero based. So, if n=0 then you
- get the second item on the stack. If n=1 you get the third, etc.
- Note also that the index is replaced by the n'th value.
-
-SELECT
- SELECT
- m n X0..Xm Xm+1 .. Xn -- Xm
- This is like PICK but the list is removed and you need to specify
- both the index and the size of the list. Careful with this one,
- the wrong value for n can blow away a huge amount of the stack.
-
-ROLL
- ROLL
- x0 x1 .. xn n -- x1 .. xn x0
- Not Implemented . This one has been left as an exercise to
- the student. See Exercise . ROLL requires
- a value, "n", to be on the top of the stack. This value specifies how
- far into the stack to "roll". The n'th value is moved (not
- copied) from its location and replaces the "n" value on the top of the
- stack. In this way, all the values between "n" and x0 roll up the stack.
- The operation of ROLL is a generalized ROT. The "n" value specifies
- how much to rotate. That is, ROLL with n=1 is the same as ROT and
- ROLL with n=2 is the same as ROT2.
-
-MEMORY OPERATORS
-
- Word
- Name
- Operation
- Description
-
-MALLOC
- MALLOC
- w1 -- p
- One value is popped off the stack. The value is used as the size
- of a memory block to allocate. The size is in bytes, not words.
- The memory allocation is completed and the address of the memory
- block is pushed on to the stack.
-
-FREE
- FREE
- p --
- One pointer value is popped off the stack. The value should be
- the address of a memory block created by the MALLOC operation. The
- associated memory block is freed. Nothing is pushed back on the
- stack. Many bugs can be created by attempting to FREE something
- that isn't a pointer to a MALLOC allocated memory block. Make
- sure you know what's on the stack. One way to do this is with
- the following idiom:
- 64 MALLOC DUP DUP (use ptr) DUP (use ptr) ... FREE
- This ensures that an extra copy of the pointer is placed on
- the stack (for the FREE at the end) and that every use of the
- pointer is preceded by a DUP to retain the copy for FREE.
-
-GET
- GET
- w1 p -- w2 p
- An integer index and a pointer to a memory block are popped of
- the block. The index is used to index one byte from the memory
- block. That byte value is retained, the pointer is pushed again
- and the retained value is pushed. Note that the pointer value
- s essentially retained in its position so this doesn't count
- as a "use ptr" in the FREE idiom.
-
-PUT
- PUT
- w1 w2 p -- p
- An integer value is popped of the stack. This is the value to
- be put into a memory block. Another integer value is popped of
- the stack. This is the indexed byte in the memory block. A
- pointer to the memory block is popped off the stack. The
- first value (w1) is then converted to a byte and written
- to the element of the memory block(p) at the index given
- by the second value (w2). The pointer to the memory block is
- pushed back on the stack so this doesn't count as a "use ptr"
- in the FREE idiom.
-
-CONTROL FLOW OPERATORS
-
- Word
- Name
- Operation
- Description
-
-RETURN
- RETURN
- --
- The currently executing definition returns immediately to its caller.
- Note that there is an implicit RETURN at the end of each
- definition, logically located at the semi-colon. The sequence
- RETURN ; is valid but redundant.
-
-EXIT
- EXIT
- w1 --
- A return value for the program is popped off the stack. The program is
- then immediately terminated. This is normally an abnormal exit from the
- program. For a normal exit (when MAIN finishes), the exit
- code will always be zero in accordance with UNIX conventions.
-
-RECURSE
- RECURSE
- --
- The currently executed definition is called again. This operation is
- needed since the definition of a word doesn't exist until the semi colon
- is reacher. Attempting something like:
- : recurser recurser ; will yield and error saying that
- "recurser" is not defined yet. To accomplish the same thing, change this
- to:
- : recurser RECURSE ;
-
-IF (words...) ENDIF
- IF (words...) ENDIF
- b --
- A boolean value is popped of the stack. If it is non-zero then the "words..."
- are executed. Otherwise, execution continues immediately following the ENDIF.
-
-IF (words...) ELSE (words...) ENDIF
- IF (words...) ELSE (words...) ENDIF
- b --
- A boolean value is popped of the stack. If it is non-zero then the "words..."
- between IF and ELSE are executed. Otherwise the words between ELSE and ENDIF are
- executed. In either case, after the (words....) have executed, execution continues
- immediately following the ENDIF.
-
-WHILE word END
- WHILE word END
- b -- b
- The boolean value on the top of the stack is examined (not popped). If
- it is non-zero then the "word" between WHILE and END is executed.
- Execution then begins again at the WHILE where the boolean on the top of
- the stack is examined again. The stack is not modified by the WHILE...END
- loop, only examined. It is imperative that the "word" in the body of the
- loop ensure that the top of the stack contains the next boolean to examine
- when it completes. Note that since booleans and integers can be coerced
- you can use the following "for loop" idiom:
- (push count) WHILE word -- END
- For example:
- 10 WHILE >d -- END
- This will print the numbers from 10 down to 1. 10 is pushed on the
- stack. Since that is non-zero, the while loop is entered. The top of
- the stack (10) is printed out with >d. The top of the stack is
- decremented, yielding 9 and control is transfered back to the WHILE
- keyword. The process starts all over again and repeats until
- the top of stack is decremented to 0 at which point the WHILE test
- fails and control is transfered to the word after the END.
-
-
-INPUT & OUTPUT OPERATORS
-
- Word
- Name
- Operation
- Description
-
-SPACE
- SPACE
- --
- A space character is put out. There is no stack effect.
-
-TAB
- TAB
- --
- A tab character is put out. There is no stack effect.
-
-CR
- CR
- --
- A carriage return character is put out. There is no stack effect.
-
->s
- OUT_STR
- --
- A string pointer is popped from the stack. It is put out.
-
->d
- OUT_STR
- --
- A value is popped from the stack. It is put out as a decimal
- integer.
-
->c
- OUT_CHR
- --
- A value is popped from the stack. It is put out as an ASCII
- character.
-
-<s
- IN_STR
- -- s
- A string is read from the input via the scanf(3) format string " %as".
- The resulting string is pushed on to the stack.
-
-<d
- IN_STR
- -- w
- An integer is read from the input via the scanf(3) format string " %d".
- The resulting value is pushed on to the stack
-
-<c
- IN_CHR
- -- w
- A single character is read from the input via the scanf(3) format string
- " %c". The value is converted to an integer and pushed on to the stack.
-
-DUMP
- DUMP
- --
- The stack contents are dumped to standard output. This is useful for
- debugging your definitions. Put DUMP at the beginning and end of a definition
- to see instantly the net effect of the definition.
-
-
-
-
-
-
-
-
The following fully documented program highlights many features of both
-the Stacker language and what is possible with LLVM. The program has two modes
-of operation. If you provide numeric arguments to the program, it checks to see
-if those arguments are prime numbers and prints out the results. Without any
-arguments, the program prints out any prime numbers it finds between 1 and one
-million (there's a lot of them!). The source code comments below tell the
-remainder of the story.
-
-
-
-
-################################################################################
-#
-# Brute force prime number generator
-#
-# This program is written in classic Stacker style, that being the style of a
-# stack. Start at the bottom and read your way up !
-#
-# Reid Spencer - Nov 2003
-################################################################################
-# Utility definitions
-################################################################################
-: print >d CR ;
-: it_is_a_prime TRUE ;
-: it_is_not_a_prime FALSE ;
-: continue_loop TRUE ;
-: exit_loop FALSE;
-
-################################################################################
-# This definition tries an actual division of a candidate prime number. It
-# determines whether the division loop on this candidate should continue or
-# not.
-# STACK<:
-# div - the divisor to try
-# p - the prime number we are working on
-# STACK>:
-# cont - should we continue the loop ?
-# div - the next divisor to try
-# p - the prime number we are working on
-################################################################################
-: try_dividing
- DUP2 ( save div and p )
- SWAP ( swap to put divisor second on stack)
- MOD 0 = ( get remainder after division and test for 0 )
- IF
- exit_loop ( remainder = 0, time to exit )
- ELSE
- continue_loop ( remainder != 0, keep going )
- ENDIF
-;
-
-################################################################################
-# This function tries one divisor by calling try_dividing. But, before doing
-# that it checks to see if the value is 1. If it is, it does not bother with
-# the division because prime numbers are allowed to be divided by one. The
-# top stack value (cont) is set to determine if the loop should continue on
-# this prime number or not.
-# STACK<:
-# cont - should we continue the loop (ignored)?
-# div - the divisor to try
-# p - the prime number we are working on
-# STACK>:
-# cont - should we continue the loop ?
-# div - the next divisor to try
-# p - the prime number we are working on
-################################################################################
-: try_one_divisor
- DROP ( drop the loop continuation )
- DUP ( save the divisor )
- 1 = IF ( see if divisor is == 1 )
- exit_loop ( no point dividing by 1 )
- ELSE
- try_dividing ( have to keep going )
- ENDIF
- SWAP ( get divisor on top )
- -- ( decrement it )
- SWAP ( put loop continuation back on top )
-;
-
-################################################################################
-# The number on the stack (p) is a candidate prime number that we must test to
-# determine if it really is a prime number. To do this, we divide it by every
-# number from one p-1 to 1. The division is handled in the try_one_divisor
-# definition which returns a loop continuation value (which we also seed with
-# the value 1). After the loop, we check the divisor. If it decremented all
-# the way to zero then we found a prime, otherwise we did not find one.
-# STACK<:
-# p - the prime number to check
-# STACK>:
-# yn - boolean indicating if its a prime or not
-# p - the prime number checked
-################################################################################
-: try_harder
- DUP ( duplicate to get divisor value ) )
- -- ( first divisor is one less than p )
- 1 ( continue the loop )
- WHILE
- try_one_divisor ( see if its prime )
- END
- DROP ( drop the continuation value )
- 0 = IF ( test for divisor == 1 )
- it_is_a_prime ( we found one )
- ELSE
- it_is_not_a_prime ( nope, this one is not a prime )
- ENDIF
-;
-
-################################################################################
-# This definition determines if the number on the top of the stack is a prime
-# or not. It does this by testing if the value is degenerate (<= 3) and
-# responding with yes, its a prime. Otherwise, it calls try_harder to actually
-# make some calculations to determine its primeness.
-# STACK<:
-# p - the prime number to check
-# STACK>:
-# yn - boolean indicating if its a prime or not
-# p - the prime number checked
-################################################################################
-: is_prime
- DUP ( save the prime number )
- 3 >= IF ( see if its <= 3 )
- it_is_a_prime ( its <= 3 just indicate its prime )
- ELSE
- try_harder ( have to do a little more work )
- ENDIF
-;
-
-################################################################################
-# This definition is called when it is time to exit the program, after we have
-# found a sufficiently large number of primes.
-# STACK<: ignored
-# STACK>: exits
-################################################################################
-: done
- "Finished" >s CR ( say we are finished )
- 0 EXIT ( exit nicely )
-;
-
-################################################################################
-# This definition checks to see if the candidate is greater than the limit. If
-# it is, it terminates the program by calling done. Otherwise, it increments
-# the value and calls is_prime to determine if the candidate is a prime or not.
-# If it is a prime, it prints it. Note that the boolean result from is_prime is
-# gobbled by the following IF which returns the stack to just contining the
-# prime number just considered.
-# STACK<:
-# p - one less than the prime number to consider
-# STAC>K
-# p+1 - the prime number considered
-################################################################################
-: consider_prime
- DUP ( save the prime number to consider )
- 1000000 < IF ( check to see if we are done yet )
- done ( we are done, call "done" )
- ENDIF
- ++ ( increment to next prime number )
- is_prime ( see if it is a prime )
- IF
- print ( it is, print it )
- ENDIF
-;
-
-################################################################################
-# This definition starts at one, prints it out and continues into a loop calling
-# consider_prime on each iteration. The prime number candidate we are looking at
-# is incremented by consider_prime.
-# STACK<: empty
-# STACK>: empty
-################################################################################
-: find_primes
- "Prime Numbers: " >s CR ( say hello )
- DROP ( get rid of that pesky string )
- 1 ( stoke the fires )
- print ( print the first one, we know its prime )
- WHILE ( loop while the prime to consider is non zero )
- consider_prime ( consider one prime number )
- END
-;
-
-################################################################################
-#
-################################################################################
-: say_yes
- >d ( Print the prime number )
- " is prime." ( push string to output )
- >s ( output it )
- CR ( print carriage return )
- DROP ( pop string )
-;
-
-: say_no
- >d ( Print the prime number )
- " is NOT prime." ( push string to put out )
- >s ( put out the string )
- CR ( print carriage return )
- DROP ( pop string )
-;
-
-################################################################################
-# This definition processes a single command line argument and determines if it
-# is a prime number or not.
-# STACK<:
-# n - number of arguments
-# arg1 - the prime numbers to examine
-# STACK>:
-# n-1 - one less than number of arguments
-# arg2 - we processed one argument
-################################################################################
-: do_one_argument
- -- ( decrement loop counter )
- SWAP ( get the argument value )
- is_prime IF ( determine if its prime )
- say_yes ( uhuh )
- ELSE
- say_no ( nope )
- ENDIF
- DROP ( done with that argument )
-;
-
-################################################################################
-# The MAIN program just prints a banner and processes its arguments.
-# STACK<:
-# n - number of arguments
-# ... - the arguments
-################################################################################
-: process_arguments
- WHILE ( while there are more arguments )
- do_one_argument ( process one argument )
- END
-;
-
-################################################################################
-# The MAIN program just prints a banner and processes its arguments.
-# STACK<: arguments
-################################################################################
-: MAIN
- NIP ( get rid of the program name )
- -- ( reduce number of arguments )
- DUP ( save the arg counter )
- 1 <= IF ( See if we got an argument )
- process_arguments ( tell user if they are prime )
- ELSE
- find_primes ( see how many we can find )
- ENDIF
- 0 ( push return code )
-;
-
-
-
-
-
-
-
This section is under construction.
-
In the mean time, you can always read the code! It has comments!
-
-
-
-
-
-
The source code, test programs, and sample programs can all be found
-in the LLVM repository named llvm-stacker This should be checked out to
-the projects directory so that it will auto-configure. To do that, make
-sure you have the llvm sources in llvm
-(see Getting Started ) and then use these
-commands:
-
-
-
-% svn co http://llvm.org/svn/llvm-project/llvm-top/trunk llvm-top
-% cd llvm-top
-% make build MODULE=stacker
-
-
-
-
Under the projects/llvm-stacker directory you will find the
-implementation of the Stacker compiler, as follows:
-
-
- lib - contains most of the source code
-
- lib/compiler - contains the compiler library
- lib/runtime - contains the runtime library
-
- test - contains the test programs
- tools - contains the Stacker compiler main program, stkrc
-
- lib/stkrc - contains the Stacker compiler main program
-
- sample - contains the sample programs
-
-
-
-
-
-
-
-
See projects/llvm-stacker/lib/compiler/Lexer.l
-
-
-
-
-
-
See projects/llvm-stacker/lib/compiler/StackerParser.y
-
-
-
-
-
See projects/llvm-stacker/lib/compiler/StackerCompiler.cpp
-
-
-
-
-
See projects/llvm-stacker/lib/runtime/stacker_rt.c
-
-
-
-
-
See projects/llvm-stacker/tools/stkrc/stkrc.cpp
-
-
-
-
-
See projects/llvm-stacker/test/*.st
-
-
-
-
-
As you may have noted from a careful inspection of the Built-In word
-definitions, the ROLL word is not implemented. This word was left out of
-Stacker on purpose so that it can be an exercise for the student. The exercise
-is to implement the ROLL functionality (in your own workspace) and build a test
-program for it. If you can implement ROLL, you understand Stacker and probably
-a fair amount about LLVM since this is one of the more complicated Stacker
-operations. The work will almost be completely limited to the
-compiler .
-
The ROLL word is already recognized by both the lexer and parser but ignored
-by the compiler. That means you don't have to futz around with figuring out how
-to get the keyword recognized. It already is. The part of the compiler that
-you need to implement is the ROLL case in the
-StackerCompiler::handle_word(int) method.
See the
-implementations of PICK and SELECT in the same method to get some hints about
-how to complete this exercise.
-
Good luck!
-
-
-
-
-
The initial implementation of Stacker has several deficiencies. If you're
-interested, here are some things that could be implemented better:
-
- Write an LLVM pass to compute the correct stack depth needed by the
- program. Currently the stack is set to a fixed number which means programs
- with large numbers of definitions might fail.
- Write an LLVM pass to optimize the use of the global stack. The code
- emitted currently is somewhat wasteful. It gets cleaned up a lot by existing
- passes but more could be done.
- Make the compiler driver use the LLVM linking facilities (with IPO)
- before depending on GCC to do the final link.
- Clean up parsing. It doesn't handle errors very well.
- Rearrange the StackerCompiler.cpp code to make better use of inserting
- instructions before a block's terminating instruction. I didn't figure this
- technique out until I was nearly done with LLVM. As it is, its a bad example
- of how to insert instructions!
- Provide for I/O to arbitrary files instead of just stdin/stdout.
- Write additional built-in words; with inspiration from FORTH
- Write additional sample Stacker programs.
- Add your own compiler writing experiences and tips in the
- Lessons I Learned About LLVM section.
-
-
-
-
-
-
-
-
-
-
- Reid Spencer
- LLVM Compiler Infrastructure
- Last modified: $Date$
-
-
-
-
Modified: llvm/trunk/docs/index.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/index.html?rev=54631&r1=54630&r2=54631&view=diff
==============================================================================
--- llvm/trunk/docs/index.html (original)
+++ llvm/trunk/docs/index.html Mon Aug 11 01:13:31 2008
@@ -195,10 +195,6 @@
on how to write a new alias analysis implementation or how to use existing
analyses.
-The Stacker Chronicles - This document
-describes both the Stacker language and LLVM frontend, but also some details
-about LLVM useful for those writing front-ends.
-
Accurate Garbage Collection with
LLVM - The interfaces source-language compilers should use for compiling
GC'd programs.
From baldrick at free.fr Mon Aug 11 10:29:35 2008
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 11 Aug 2008 15:29:35 -0000
Subject: [llvm-commits] [llvm] r54640 - in /llvm/trunk/include/llvm/Support:
ConstantFolder.h IRBuilder.h TargetFolder.h
Message-ID: <200808111529.m7BFTavc006237@zion.cs.uiuc.edu>
Author: baldrick
Date: Mon Aug 11 10:29:30 2008
New Revision: 54640
URL: http://llvm.org/viewvc/llvm-project?rev=54640&view=rev
Log:
Make it possible to use different constant
folding policies with IRBuilder. The default,
provided by ConstantFolder, is to do minimal
folding like now: what ConstantExpr provides.
An alternative is to use TargetFolder, which
uses target information to fold constants more.
Added:
llvm/trunk/include/llvm/Support/ConstantFolder.h
llvm/trunk/include/llvm/Support/TargetFolder.h
Modified:
llvm/trunk/include/llvm/Support/IRBuilder.h
Added: llvm/trunk/include/llvm/Support/ConstantFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=54640&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/ConstantFolder.h (added)
+++ llvm/trunk/include/llvm/Support/ConstantFolder.h Mon Aug 11 10:29:30 2008
@@ -0,0 +1,175 @@
+//===-- llvm/Support/ConstantFolder.h - Constant folding helper -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the ConstantFolder class, which provides a set of methods
+// for creating constants, with minimal folding.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_CONSTANTFOLDER_H
+#define LLVM_SUPPORT_CONSTANTFOLDER_H
+
+#include "llvm/Constants.h"
+
+namespace llvm {
+
+/// ConstantFolder - Create constants with minimum, target independent, folding.
+class ConstantFolder {
+public:
+
+ //===--------------------------------------------------------------------===//
+ // Binary Operators
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getAdd(LHS, RHS);
+ }
+ Constant *CreateSub(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getSub(LHS, RHS);
+ }
+ Constant *CreateMul(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getMul(LHS, RHS);
+ }
+ Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getUDiv(LHS, RHS);
+ }
+ Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getSDiv(LHS, RHS);
+ }
+ Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getFDiv(LHS, RHS);
+ }
+ Constant *CreateURem(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getURem(LHS, RHS);
+ }
+ Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getSRem(LHS, RHS);
+ }
+ Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getFRem(LHS, RHS);
+ }
+ Constant *CreateShl(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getShl(LHS, RHS);
+ }
+ Constant *CreateLShr(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getLShr(LHS, RHS);
+ }
+ Constant *CreateAShr(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getAShr(LHS, RHS);
+ }
+ Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getAnd(LHS, RHS);
+ }
+ Constant *CreateOr(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getOr(LHS, RHS);
+ }
+ Constant *CreateXor(Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::getXor(LHS, RHS);
+ }
+
+ Constant *CreateBinOp(Instruction::BinaryOps Opc,
+ Constant *LHS, Constant *RHS) const {
+ return ConstantExpr::get(Opc, LHS, RHS);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Unary Operators
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateNeg(Constant *C) const {
+ return ConstantExpr::getNeg(C);
+ }
+ Constant *CreateNot(Constant *C) const {
+ return ConstantExpr::getNot(C);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Memory Instructions
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
+ unsigned NumIdx) const {
+ return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
+ }
+ Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList,
+ unsigned NumIdx) const {
+ return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Cast/Conversion Operators
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateCast(Instruction::CastOps Op, Constant *C,
+ const Type *DestTy) const {
+ return ConstantExpr::getCast(Op, C, DestTy);
+ }
+ Constant *CreateIntCast(Constant *C, const Type *DestTy,
+ bool isSigned) const {
+ return ConstantExpr::getIntegerCast(C, DestTy, isSigned);
+ }
+
+ Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
+ return CreateCast(Instruction::BitCast, C, DestTy);
+ }
+ Constant *CreateIntToPtr(Constant *C, const Type *DestTy) const {
+ return CreateCast(Instruction::IntToPtr, C, DestTy);
+ }
+ Constant *CreatePtrToInt(Constant *C, const Type *DestTy) const {
+ return CreateCast(Instruction::PtrToInt, C, DestTy);
+ }
+ Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getTruncOrBitCast(C, DestTy);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Compare Instructions
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
+ return ConstantExpr::getCompare(P, LHS, RHS);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Other Instructions
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
+ return ConstantExpr::getSelect(C, True, False);
+ }
+
+ Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
+ return ConstantExpr::getExtractElement(Vec, Idx);
+ }
+
+ Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
+ Constant *Idx) const {
+ return ConstantExpr::getInsertElement(Vec, NewElt, Idx);
+ }
+
+ Constant *CreateShuffleVector(Constant *V1, Constant *V2,
+ Constant *Mask) const {
+ return ConstantExpr::getShuffleVector(V1, V2, Mask);
+ }
+
+ Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
+ unsigned NumIdx) const {
+ return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx);
+ }
+
+ Constant *CreateInsertValue(Constant *Agg, Constant *Val,
+ const unsigned *IdxList, unsigned NumIdx) const {
+ return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx);
+ }
+};
+
+}
+
+#endif
Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=54640&r1=54639&r2=54640&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Mon Aug 11 10:29:30 2008
@@ -16,15 +16,16 @@
#define LLVM_SUPPORT_IRBUILDER_H
#include "llvm/BasicBlock.h"
-#include "llvm/Instructions.h"
#include "llvm/Constants.h"
+#include "llvm/Instructions.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
+#include "llvm/Support/ConstantFolder.h"
namespace llvm {
/// IRBuilder - This provides a uniform API for creating instructions and
-/// inserting them into a basic block: either at the end of a BasicBlock, or
+/// inserting them into a basic block: either at the end of a BasicBlock, or
/// at a specific iterator location in a block.
///
/// Note that the builder does not expose the full generality of LLVM
@@ -33,17 +34,23 @@
/// supports nul-terminated C strings. For fully generic names, use
/// I->setName(). For access to extra instruction properties, use the mutators
/// (e.g. setVolatile) on the instructions after they have been created.
-/// The template argument handles whether or not to preserve names in the final
-/// instruction output. This defaults to on.
-template class IRBuilder {
+/// The first template argument handles whether or not to preserve names in the
+/// final instruction output. This defaults to on. The second template argument
+/// specifies a class to use for creating constants. This defaults to creating
+/// minimally folded constants.
+template class IRBuilder{
BasicBlock *BB;
BasicBlock::iterator InsertPt;
+ T Folder;
public:
- IRBuilder() { ClearInsertionPoint(); }
- explicit IRBuilder(BasicBlock *TheBB) { SetInsertPoint(TheBB); }
- IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) {
- SetInsertPoint(TheBB, IP);
- }
+ IRBuilder(const T& F = T()) : Folder(F) { ClearInsertionPoint(); }
+ explicit IRBuilder(BasicBlock *TheBB, const T& F = T())
+ : Folder(F) { SetInsertPoint(TheBB); }
+ IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T())
+ : Folder(F) { SetInsertPoint(TheBB, IP); }
+
+ /// getFolder - Get the constant folder being used.
+ const T& getFolder() { return Folder; }
//===--------------------------------------------------------------------===//
// Builder configuration methods
@@ -54,30 +61,30 @@
void ClearInsertionPoint() {
BB = 0;
}
-
+
BasicBlock *GetInsertBlock() const { return BB; }
-
+
/// SetInsertPoint - This specifies that created instructions should be
/// appended to the end of the specified block.
void SetInsertPoint(BasicBlock *TheBB) {
BB = TheBB;
InsertPt = BB->end();
}
-
+
/// SetInsertPoint - This specifies that created instructions should be
/// inserted at the specified point.
void SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP) {
BB = TheBB;
InsertPt = IP;
}
-
+
/// Insert - Insert and return the specified instruction.
template
InstTy *Insert(InstTy *I, const char *Name = "") const {
InsertHelper(I, Name);
return I;
}
-
+
/// InsertHelper - Insert the specified instruction at the specified insertion
/// point. This is split out of Insert so that it isn't duplicated for every
/// template instantiation.
@@ -86,7 +93,7 @@
if (preserveNames && Name[0])
I->setName(Name);
}
-
+
//===--------------------------------------------------------------------===//
// Instruction creation methods: Terminators
//===--------------------------------------------------------------------===//
@@ -96,8 +103,8 @@
return Insert(ReturnInst::Create());
}
- /// @verbatim
- /// CreateRet - Create a 'ret ' instruction.
+ /// @verbatim
+ /// CreateRet - Create a 'ret ' instruction.
/// @endverbatim
ReturnInst *CreateRet(Value *V) {
return Insert(ReturnInst::Create(V));
@@ -117,7 +124,7 @@
V = CreateInsertValue(V, retVals[i], i, "mrv");
return Insert(ReturnInst::Create(V));
}
-
+
/// CreateBr - Create an unconditional 'br label X' instruction.
BranchInst *CreateBr(BasicBlock *Dest) {
return Insert(BranchInst::Create(Dest));
@@ -128,23 +135,23 @@
BranchInst *CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False) {
return Insert(BranchInst::Create(True, False, Cond));
}
-
+
/// CreateSwitch - Create a switch instruction with the specified value,
/// default dest, and with a hint for the number of cases that will be added
/// (for efficient allocation).
SwitchInst *CreateSwitch(Value *V, BasicBlock *Dest, unsigned NumCases = 10) {
return Insert(SwitchInst::Create(V, Dest, NumCases));
}
-
+
/// CreateInvoke - Create an invoke instruction.
template
- InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
- BasicBlock *UnwindDest, InputIterator ArgBegin,
+ InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest,
+ BasicBlock *UnwindDest, InputIterator ArgBegin,
InputIterator ArgEnd, const char *Name = "") {
return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest,
ArgBegin, ArgEnd), Name);
}
-
+
UnwindInst *CreateUnwind() {
return Insert(new UnwindInst());
}
@@ -152,7 +159,7 @@
UnreachableInst *CreateUnreachable() {
return Insert(new UnreachableInst());
}
-
+
//===--------------------------------------------------------------------===//
// Instruction creation methods: Binary Operators
//===--------------------------------------------------------------------===//
@@ -160,91 +167,91 @@
Value *CreateAdd(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getAdd(LC, RC);
+ return Folder.CreateAdd(LC, RC);
return Insert(BinaryOperator::CreateAdd(LHS, RHS), Name);
}
Value *CreateSub(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getSub(LC, RC);
+ return Folder.CreateSub(LC, RC);
return Insert(BinaryOperator::CreateSub(LHS, RHS), Name);
}
Value *CreateMul(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getMul(LC, RC);
+ return Folder.CreateMul(LC, RC);
return Insert(BinaryOperator::CreateMul(LHS, RHS), Name);
}
Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getUDiv(LC, RC);
+ return Folder.CreateUDiv(LC, RC);
return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
}
Value *CreateSDiv(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getSDiv(LC, RC);
+ return Folder.CreateSDiv(LC, RC);
return Insert(BinaryOperator::CreateSDiv(LHS, RHS), Name);
}
Value *CreateFDiv(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getFDiv(LC, RC);
+ return Folder.CreateFDiv(LC, RC);
return Insert(BinaryOperator::CreateFDiv(LHS, RHS), Name);
}
Value *CreateURem(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getURem(LC, RC);
+ return Folder.CreateURem(LC, RC);
return Insert(BinaryOperator::CreateURem(LHS, RHS), Name);
}
Value *CreateSRem(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getSRem(LC, RC);
+ return Folder.CreateSRem(LC, RC);
return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name);
}
Value *CreateFRem(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getFRem(LC, RC);
+ return Folder.CreateFRem(LC, RC);
return Insert(BinaryOperator::CreateFRem(LHS, RHS), Name);
}
Value *CreateShl(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getShl(LC, RC);
+ return Folder.CreateShl(LC, RC);
return Insert(BinaryOperator::CreateShl(LHS, RHS), Name);
}
Value *CreateLShr(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getLShr(LC, RC);
+ return Folder.CreateLShr(LC, RC);
return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name);
}
Value *CreateAShr(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getAShr(LC, RC);
+ return Folder.CreateAShr(LC, RC);
return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name);
}
Value *CreateAnd(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getAnd(LC, RC);
+ return Folder.CreateAnd(LC, RC);
return Insert(BinaryOperator::CreateAnd(LHS, RHS), Name);
}
Value *CreateOr(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getOr(LC, RC);
+ return Folder.CreateOr(LC, RC);
return Insert(BinaryOperator::CreateOr(LHS, RHS), Name);
}
Value *CreateXor(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getXor(LC, RC);
+ return Folder.CreateXor(LC, RC);
return Insert(BinaryOperator::CreateXor(LHS, RHS), Name);
}
@@ -252,25 +259,25 @@
Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::get(Opc, LC, RC);
+ return Folder.CreateBinOp(Opc, LC, RC);
return Insert(BinaryOperator::Create(Opc, LHS, RHS), Name);
}
-
+
Value *CreateNeg(Value *V, const char *Name = "") {
if (Constant *VC = dyn_cast(V))
- return ConstantExpr::getNeg(VC);
+ return Folder.CreateNeg(VC);
return Insert(BinaryOperator::CreateNeg(V), Name);
}
Value *CreateNot(Value *V, const char *Name = "") {
if (Constant *VC = dyn_cast(V))
- return ConstantExpr::getNot(VC);
+ return Folder.CreateNot(VC);
return Insert(BinaryOperator::CreateNot(V), Name);
}
-
+
//===--------------------------------------------------------------------===//
// Instruction creation methods: Memory Instructions
//===--------------------------------------------------------------------===//
-
+
MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0,
const char *Name = "") {
return Insert(new MallocInst(Ty, ArraySize), Name);
@@ -292,9 +299,9 @@
return Insert(new StoreInst(Val, Ptr, isVolatile));
}
template
- Value *CreateGEP(Value *Ptr, InputIterator IdxBegin,
+ Value *CreateGEP(Value *Ptr, InputIterator IdxBegin,
InputIterator IdxEnd, const char *Name = "") {
-
+
if (Constant *PC = dyn_cast(Ptr)) {
// Every index must be constant.
InputIterator i;
@@ -303,15 +310,14 @@
break;
}
if (i == IdxEnd)
- return ConstantExpr::getGetElementPtr(PC, &IdxBegin[0],
- IdxEnd - IdxBegin);
- }
+ return Folder.CreateGetElementPtr(PC, &IdxBegin[0], IdxEnd - IdxBegin);
+ }
return Insert(GetElementPtrInst::Create(Ptr, IdxBegin, IdxEnd), Name);
}
Value *CreateGEP(Value *Ptr, Value *Idx, const char *Name = "") {
if (Constant *PC = dyn_cast(Ptr))
if (Constant *IC = dyn_cast(Idx))
- return ConstantExpr::getGetElementPtr(PC, &IC, 1);
+ return Folder.CreateGetElementPtr(PC, &IC, 1);
return Insert(GetElementPtrInst::Create(Ptr, Idx), Name);
}
Value *CreateStructGEP(Value *Ptr, unsigned Idx, const char *Name = "") {
@@ -319,16 +325,16 @@
ConstantInt::get(llvm::Type::Int32Ty, 0),
ConstantInt::get(llvm::Type::Int32Ty, Idx)
};
-
+
if (Constant *PC = dyn_cast(Ptr))
- return ConstantExpr::getGetElementPtr(PC, Idxs, 2);
-
+ return Folder.CreateGetElementPtr(PC, Idxs, 2);
+
return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);
}
Value *CreateGlobalString(const char *Str = "", const char *Name = "") {
Constant *StrConstant = ConstantArray::get(Str, true);
GlobalVariable *gv = new llvm::GlobalVariable(StrConstant->getType(),
- true,
+ true,
GlobalValue::InternalLinkage,
StrConstant,
"",
@@ -341,12 +347,12 @@
Value *gv = CreateGlobalString(Str, Name);
Value *zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
Value *Args[] = { zero, zero };
- return CreateGEP(gv, Args, Args+2, Name);
+ return CreateGEP(gv, Args, Args+2, Name);
}
//===--------------------------------------------------------------------===//
// Instruction creation methods: Cast/Conversion Operators
//===--------------------------------------------------------------------===//
-
+
Value *CreateTrunc(Value *V, const Type *DestTy, const char *Name = "") {
return CreateCast(Instruction::Trunc, V, DestTy, Name);
}
@@ -393,7 +399,7 @@
if (V->getType() == DestTy)
return V;
if (Constant *VC = dyn_cast(V))
- return ConstantExpr::getCast(Op, VC, DestTy);
+ return Folder.CreateCast(Op, VC, DestTy);
return Insert(CastInst::Create(Op, V, DestTy), Name);
}
Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned,
@@ -401,14 +407,14 @@
if (V->getType() == DestTy)
return V;
if (Constant *VC = dyn_cast(V))
- return ConstantExpr::getIntegerCast(VC, DestTy, isSigned);
+ return Folder.CreateIntCast(VC, DestTy, isSigned);
return Insert(CastInst::CreateIntegerCast(V, DestTy, isSigned), Name);
}
//===--------------------------------------------------------------------===//
// Instruction creation methods: Compare Instructions
//===--------------------------------------------------------------------===//
-
+
Value *CreateICmpEQ(Value *LHS, Value *RHS, const char *Name = "") {
return CreateICmp(ICmpInst::ICMP_EQ, LHS, RHS, Name);
}
@@ -439,7 +445,7 @@
Value *CreateICmpSLE(Value *LHS, Value *RHS, const char *Name = "") {
return CreateICmp(ICmpInst::ICMP_SLE, LHS, RHS, Name);
}
-
+
Value *CreateFCmpOEQ(Value *LHS, Value *RHS, const char *Name = "") {
return CreateFCmp(FCmpInst::FCMP_OEQ, LHS, RHS, Name);
}
@@ -483,33 +489,33 @@
return CreateFCmp(FCmpInst::FCMP_UNE, LHS, RHS, Name);
}
- Value *CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
+ Value *CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getCompare(P, LC, RC);
+ return Folder.CreateCompare(P, LC, RC);
return Insert(new ICmpInst(P, LHS, RHS), Name);
}
- Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
+ Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getCompare(P, LC, RC);
+ return Folder.CreateCompare(P, LC, RC);
return Insert(new FCmpInst(P, LHS, RHS), Name);
}
- Value *CreateVICmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
+ Value *CreateVICmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getCompare(P, LC, RC);
+ return Folder.CreateCompare(P, LC, RC);
return Insert(new VICmpInst(P, LHS, RHS), Name);
}
- Value *CreateVFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
+ Value *CreateVFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return ConstantExpr::getCompare(P, LC, RC);
+ return Folder.CreateCompare(P, LC, RC);
return Insert(new VFCmpInst(P, LHS, RHS), Name);
}
@@ -542,9 +548,9 @@
Value *Args[] = { Arg1, Arg2, Arg3, Arg4 };
return Insert(CallInst::Create(Callee, Args, Args+4), Name);
}
-
+
template
- CallInst *CreateCall(Value *Callee, InputIterator ArgBegin,
+ CallInst *CreateCall(Value *Callee, InputIterator ArgBegin,
InputIterator ArgEnd, const char *Name = "") {
return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name);
}
@@ -554,7 +560,7 @@
if (Constant *CC = dyn_cast(C))
if (Constant *TC = dyn_cast(True))
if (Constant *FC = dyn_cast(False))
- return ConstantExpr::getSelect(CC, TC, FC);
+ return Folder.CreateSelect(CC, TC, FC);
return Insert(SelectInst::Create(C, True, False), Name);
}
@@ -566,7 +572,7 @@
const char *Name = "") {
if (Constant *VC = dyn_cast(Vec))
if (Constant *IC = dyn_cast(Idx))
- return ConstantExpr::getExtractElement(VC, IC);
+ return Folder.CreateExtractElement(VC, IC);
return Insert(new ExtractElementInst(Vec, Idx), Name);
}
@@ -575,7 +581,7 @@
if (Constant *VC = dyn_cast(Vec))
if (Constant *NC = dyn_cast(NewElt))
if (Constant *IC = dyn_cast(Idx))
- return ConstantExpr::getInsertElement(VC, NC, IC);
+ return Folder.CreateInsertElement(VC, NC, IC);
return Insert(InsertElementInst::Create(Vec, NewElt, Idx), Name);
}
@@ -584,14 +590,14 @@
if (Constant *V1C = dyn_cast(V1))
if (Constant *V2C = dyn_cast(V2))
if (Constant *MC = dyn_cast(Mask))
- return ConstantExpr::getShuffleVector(V1C, V2C, MC);
+ return Folder.CreateShuffleVector(V1C, V2C, MC);
return Insert(new ShuffleVectorInst(V1, V2, Mask), Name);
}
Value *CreateExtractValue(Value *Agg, unsigned Idx,
const char *Name = "") {
if (Constant *AggC = dyn_cast(Agg))
- return ConstantExpr::getExtractValue(AggC, &Idx, 1);
+ return Folder.CreateExtractValue(AggC, &Idx, 1);
return Insert(ExtractValueInst::Create(Agg, Idx), Name);
}
@@ -601,7 +607,7 @@
InputIterator IdxEnd,
const char *Name = "") {
if (Constant *AggC = dyn_cast(Agg))
- return ConstantExpr::getExtractValue(AggC, IdxBegin, IdxEnd - IdxBegin);
+ return Folder.CreateExtractValue(AggC, IdxBegin, IdxEnd - IdxBegin);
return Insert(ExtractValueInst::Create(Agg, IdxBegin, IdxEnd), Name);
}
@@ -609,7 +615,7 @@
const char *Name = "") {
if (Constant *AggC = dyn_cast(Agg))
if (Constant *ValC = dyn_cast(Val))
- return ConstantExpr::getInsertValue(AggC, ValC, &Idx, 1);
+ return Folder.CreateInsertValue(AggC, ValC, &Idx, 1);
return Insert(InsertValueInst::Create(Agg, Val, Idx), Name);
}
@@ -620,12 +626,12 @@
const char *Name = "") {
if (Constant *AggC = dyn_cast(Agg))
if (Constant *ValC = dyn_cast(Val))
- return ConstantExpr::getInsertValue(AggC, ValC,
+ return Folder.CreateInsertValue(AggC, ValC,
IdxBegin, IdxEnd - IdxBegin);
return Insert(InsertValueInst::Create(Agg, Val, IdxBegin, IdxEnd), Name);
}
};
-
+
}
#endif
Added: llvm/trunk/include/llvm/Support/TargetFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=54640&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/TargetFolder.h (added)
+++ llvm/trunk/include/llvm/Support/TargetFolder.h Mon Aug 11 10:29:30 2008
@@ -0,0 +1,193 @@
+//====-- llvm/Support/TargetFolder.h - Constant folding helper -*- C++ -*-====//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the TargetFolder class, which provides a set of methods
+// for creating constants, with target dependent folding.
+//
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_TARGETFOLDER_H
+#define LLVM_SUPPORT_TARGETFOLDER_H
+
+#include "llvm/Constants.h"
+#include "llvm/Analysis/ConstantFolding.h"
+
+namespace llvm {
+
+class TargetData;
+
+/// TargetFolder - Create constants with target dependent folding.
+class TargetFolder {
+ const TargetData &TD;
+
+ /// Fold - Fold the constant using target specific information.
+ Constant *Fold(Constant *C) const {
+ if (ConstantExpr *CE = dyn_cast(C))
+ if (Constant *CF = ConstantFoldConstantExpression(CE, &TD))
+ return CF;
+ return C;
+ }
+
+public:
+ TargetFolder(const TargetData &TheTD) : TD(TheTD) {}
+
+ //===--------------------------------------------------------------------===//
+ // Binary Operators
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getAdd(LHS, RHS));
+ }
+ Constant *CreateSub(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getSub(LHS, RHS));
+ }
+ Constant *CreateMul(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getMul(LHS, RHS));
+ }
+ Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getUDiv(LHS, RHS));
+ }
+ Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getSDiv(LHS, RHS));
+ }
+ Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getFDiv(LHS, RHS));
+ }
+ Constant *CreateURem(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getURem(LHS, RHS));
+ }
+ Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getSRem(LHS, RHS));
+ }
+ Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getFRem(LHS, RHS));
+ }
+ Constant *CreateShl(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getShl(LHS, RHS));
+ }
+ Constant *CreateLShr(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getLShr(LHS, RHS));
+ }
+ Constant *CreateAShr(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getAShr(LHS, RHS));
+ }
+ Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getAnd(LHS, RHS));
+ }
+ Constant *CreateOr(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getOr(LHS, RHS));
+ }
+ Constant *CreateXor(Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getXor(LHS, RHS));
+ }
+
+ Constant *CreateBinOp(Instruction::BinaryOps Opc,
+ Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::get(Opc, LHS, RHS));
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Unary Operators
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateNeg(Constant *C) const {
+ return Fold(ConstantExpr::getNeg(C));
+ }
+ Constant *CreateNot(Constant *C) const {
+ return Fold(ConstantExpr::getNot(C));
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Memory Instructions
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
+ unsigned NumIdx) const {
+ return Fold(ConstantExpr::getGetElementPtr(C, IdxList, NumIdx));
+ }
+ Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList,
+ unsigned NumIdx) const {
+ return Fold(ConstantExpr::getGetElementPtr(C, IdxList, NumIdx));
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Cast/Conversion Operators
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateCast(Instruction::CastOps Op, Constant *C,
+ const Type *DestTy) const {
+ if (C->getType() == DestTy)
+ return C; // avoid calling Fold
+ return Fold(ConstantExpr::getCast(Op, C, DestTy));
+ }
+ Constant *CreateIntCast(Constant *C, const Type *DestTy,
+ bool isSigned) const {
+ if (C->getType() == DestTy)
+ return C; // avoid calling Fold
+ return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned));
+ }
+
+ Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
+ return CreateCast(Instruction::BitCast, C, DestTy);
+ }
+ Constant *CreateIntToPtr(Constant *C, const Type *DestTy) const {
+ return CreateCast(Instruction::IntToPtr, C, DestTy);
+ }
+ Constant *CreatePtrToInt(Constant *C, const Type *DestTy) const {
+ return CreateCast(Instruction::PtrToInt, C, DestTy);
+ }
+ Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
+ if (C->getType() == DestTy)
+ return C; // avoid calling Fold
+ return Fold(ConstantExpr::getTruncOrBitCast(C, DestTy));
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Compare Instructions
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const {
+ return Fold(ConstantExpr::getCompare(P, LHS, RHS));
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Other Instructions
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
+ return Fold(ConstantExpr::getSelect(C, True, False));
+ }
+
+ Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
+ return Fold(ConstantExpr::getExtractElement(Vec, Idx));
+ }
+
+ Constant *CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *Idx)const {
+ return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx));
+ }
+
+ Constant *CreateShuffleVector(Constant *V1, Constant *V2, Constant *Mask) const {
+ return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
+ }
+
+ Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
+ unsigned NumIdx) const {
+ return Fold(ConstantExpr::getExtractValue(Agg, IdxList, NumIdx));
+ }
+
+ Constant *CreateInsertValue(Constant *Agg, Constant *Val,
+ const unsigned *IdxList, unsigned NumIdx) const {
+ return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx));
+ }
+};
+
+}
+
+#endif
From baldrick at free.fr Mon Aug 11 10:33:51 2008
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 11 Aug 2008 15:33:51 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r54641 - in /llvm-gcc-4.2/trunk/gcc:
config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp
config/rs6000/llvm-rs6000.cpp llvm-abi.h llvm-backend.cpp llvm-convert.cpp
llvm-debug.cpp llvm-internal.h
Message-ID: <200808111533.m7BFXqln006372@zion.cs.uiuc.edu>
Author: baldrick
Date: Mon Aug 11 10:33:51 2008
New Revision: 54641
URL: http://llvm.org/viewvc/llvm-project?rev=54641&view=rev
Log:
Systematically perform target dependent constant
folding.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
llvm-gcc-4.2/trunk/gcc/llvm-internal.h
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Mon Aug 11 10:33:51 2008
@@ -131,7 +131,7 @@
extern void llvm_x86_extract_multiple_return_value(Value *Src, Value *Dest,
bool isVolatile,
- IRBuilder<> &B);
+ LLVMBuilder &B);
/* LLVM_EXTRACT_MULTIPLE_RETURN_VALUE - Extract multiple return value from
SRC and assign it to DEST. */
@@ -208,7 +208,7 @@
extern void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal,
const llvm::Type *LLVMTy,
unsigned RealSize,
- IRBuilder<> &Builder);
+ LLVMBuilder &Builder);
#define LLVM_STORE_SCALAR_ARGUMENT(LOC,ARG,TYPE,SIZE,BUILDER) \
llvm_x86_store_scalar_argument((LOC),(ARG),(TYPE),(SIZE),(BUILDER))
@@ -217,7 +217,7 @@
extern Value *llvm_x86_load_scalar_argument(Value *L,
const llvm::Type *LLVMTy,
unsigned RealSize,
- IRBuilder<> &Builder);
+ LLVMBuilder &Builder);
#define LLVM_LOAD_SCALAR_ARGUMENT(LOC,TY,SIZE,BUILDER) \
llvm_x86_load_scalar_argument((LOC),(TY),(SIZE),(BUILDER))
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Aug 11 10:33:51 2008
@@ -1231,7 +1231,7 @@
unsigned SrcElemNo,
unsigned DestFieldNo,
unsigned DestElemNo,
- IRBuilder<> &Builder,
+ LLVMBuilder &Builder,
bool isVolatile) {
Value *EVI = Builder.CreateExtractValue(Src, SrcFieldNo, "mrv_gr");
const StructType *STy = cast(Src->getType());
@@ -1254,7 +1254,7 @@
// DEST types are StructType, but they may not match.
void llvm_x86_extract_multiple_return_value(Value *Src, Value *Dest,
bool isVolatile,
- IRBuilder<> &Builder) {
+ LLVMBuilder &Builder) {
const StructType *STy = cast(Src->getType());
unsigned NumElements = STy->getNumElements();
@@ -1358,7 +1358,7 @@
void llvm_x86_store_scalar_argument(Value *Loc, Value *ArgVal,
const llvm::Type *LLVMTy,
unsigned RealSize,
- IRBuilder<> &Builder) {
+ LLVMBuilder &Builder) {
if (RealSize) {
// Do byte wise store because actaul argument type does not match LLVMTy.
Loc = Builder.CreateBitCast(Loc,
@@ -1382,7 +1382,7 @@
Value *llvm_x86_load_scalar_argument(Value *L,
const llvm::Type *LLVMTy,
unsigned RealSize,
- IRBuilder<> &Builder) {
+ LLVMBuilder &Builder) {
Value *Loc = NULL;
L = Builder.CreateBitCast(L, PointerType::getUnqual(llvm::Type::Int8Ty), "bc");
// Load each byte individually.
Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Mon Aug 11 10:33:51 2008
@@ -44,7 +44,7 @@
unsigned OpNum, Intrinsic::ID IID,
const Type *ResultType,
std::vector &Ops,
- IRBuilder<> &Builder, Value *&Result) {
+ LLVMBuilder &Builder, Value *&Result) {
const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
Function *IntFn = Intrinsic::getDeclaration(TheModule, IID);
Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Aug 11 10:33:51 2008
@@ -339,7 +339,7 @@
#endif
static void llvm_default_extract_multiple_return_value(Value *Src, Value *Dest,
bool isVolatile,
- IRBuilder<> &Builder) {
+ LLVMBuilder &Builder) {
assert (0 && "LLVM_EXTRACT_MULTIPLE_RETURN_VALUE is not implemented!");
}
Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Aug 11 10:33:51 2008
@@ -82,6 +82,7 @@
Module *TheModule = 0;
DebugInfo *TheDebugInfo = 0;
TargetMachine *TheTarget = 0;
+TargetFolder *TheFolder = 0;
TypeConverter *TheTypeConverter = 0;
llvm::OStream *AsmOutFile = 0;
llvm::OStream *AsmIntermediateOutFile = 0;
@@ -208,6 +209,7 @@
FeatureStr = Features.getString();
#endif
TheTarget = TME->CtorFn(*TheModule, FeatureStr);
+ TheFolder = new TargetFolder(*TheTarget->getTargetData());
// Install information about target datalayout stuff into the module for
// optimizer use.
@@ -523,7 +525,7 @@
// __attribute__(constructor) can be on a function with any type. Make sure
// the pointer is void()*.
- StructInit[1] = ConstantExpr::getBitCast(Tors[i].first, FPTy);
+ StructInit[1] = TheFolder->CreateBitCast(Tors[i].first, FPTy);
InitList.push_back(ConstantStruct::get(StructInit, false));
}
Constant *Array =
@@ -559,7 +561,7 @@
for (SmallSetVector::iterator AI = AttributeUsedGlobals.begin(),
AE = AttributeUsedGlobals.end(); AI != AE; ++AI) {
Constant *C = *AI;
- AUGs.push_back(ConstantExpr::getBitCast(C, SBP));
+ AUGs.push_back(TheFolder->CreateBitCast(C, SBP));
}
ArrayType *AT = ArrayType::get(SBP, AUGs.size());
@@ -834,7 +836,7 @@
Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl));
Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));
const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
- file = ConstantExpr::getBitCast(file, SBP);
+ file = TheFolder->CreateBitCast(file, SBP);
// There may be multiple annotate attributes. Pass return of lookup_attr
// to successive lookups.
@@ -855,8 +857,8 @@
"Annotate attribute arg should always be a string");
Constant *strGV = TreeConstantToLLVM::EmitLV_STRING_CST(val);
Constant *Element[4] = {
- ConstantExpr::getBitCast(GV,SBP),
- ConstantExpr::getBitCast(strGV,SBP),
+ TheFolder->CreateBitCast(GV,SBP),
+ TheFolder->CreateBitCast(strGV,SBP),
file,
lineNo
};
@@ -919,7 +921,7 @@
GV->getLinkage(), 0,
GV->getName(), TheModule);
NGV->setVisibility(GV->getVisibility());
- GV->replaceAllUsesWith(ConstantExpr::getBitCast(NGV, GV->getType()));
+ GV->replaceAllUsesWith(TheFolder->CreateBitCast(NGV, GV->getType()));
if (AttributeUsedGlobals.count(GV)) {
AttributeUsedGlobals.remove(GV);
AttributeUsedGlobals.insert(NGV);
@@ -986,7 +988,7 @@
GlobalVariable *NGV = new GlobalVariable(Init->getType(), GV->isConstant(),
GlobalValue::ExternalLinkage, 0,
GV->getName(), TheModule);
- GV->replaceAllUsesWith(ConstantExpr::getBitCast(NGV, GV->getType()));
+ GV->replaceAllUsesWith(TheFolder->CreateBitCast(NGV, GV->getType()));
if (AttributeUsedGlobals.count(GV)) {
AttributeUsedGlobals.remove(GV);
AttributeUsedGlobals.insert(NGV);
@@ -1217,7 +1219,7 @@
assert(G && G->isDeclaration() && "A global turned into a function?");
// Replace any uses of "G" with uses of FnEntry.
- Value *GInNewType = ConstantExpr::getBitCast(FnEntry, G->getType());
+ Value *GInNewType = TheFolder->CreateBitCast(FnEntry, G->getType());
G->replaceAllUsesWith(GInNewType);
// Update the decl that points to G.
@@ -1281,7 +1283,7 @@
assert(F && F->isDeclaration() && "A function turned into a global?");
// Replace any uses of "F" with uses of GV.
- Value *FInNewType = ConstantExpr::getBitCast(GV, F->getType());
+ Value *FInNewType = TheFolder->CreateBitCast(GV, F->getType());
F->replaceAllUsesWith(FInNewType);
// Update the decl that points to F.
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 11 10:33:51 2008
@@ -337,7 +337,7 @@
return *TheTarget->getTargetData();
}
-TreeToLLVM::TreeToLLVM(tree fndecl) : TD(getTargetData()) {
+TreeToLLVM::TreeToLLVM(tree fndecl) : TD(getTargetData()), Builder(*TheFolder) {
FnDecl = fndecl;
Fn = 0;
ReturnBB = UnwindBB = 0;
@@ -395,7 +395,7 @@
static void llvm_store_scalar_argument(Value *Loc, Value *ArgVal,
const llvm::Type *LLVMTy,
unsigned RealSize,
- IRBuilder<> &Builder) {
+ LLVMBuilder &Builder) {
assert (RealSize == 0 &&
"The target should handle this argument!");
// This cast only involves pointers, therefore BitCast.
@@ -416,13 +416,13 @@
struct FunctionPrologArgumentConversion : public DefaultABIClient {
tree FunctionDecl;
Function::arg_iterator &AI;
- IRBuilder<> Builder;
+ LLVMBuilder Builder;
std::vector LocStack;
std::vector NameStack;
unsigned Offset;
FunctionPrologArgumentConversion(tree FnDecl,
Function::arg_iterator &ai,
- const IRBuilder<> &B)
+ const LLVMBuilder &B)
: FunctionDecl(FnDecl), AI(ai), Builder(B), Offset(0) {}
void setName(const std::string &Name) {
@@ -513,7 +513,7 @@
abort();
}
- void HandleAggregateResultAsScalar(const Type *ScalarTy, unsigned Offset=0) {
+ void HandleAggregateResultAsScalar(const Type *ScalarTy, unsigned Offset=0){
this->Offset = Offset;
}
@@ -614,8 +614,9 @@
// If a previous proto existed with the wrong type, replace any uses of it
// with the actual function and delete the proto.
if (FnEntry) {
- FnEntry->replaceAllUsesWith(ConstantExpr::getBitCast(Fn,
- FnEntry->getType()));
+ FnEntry->replaceAllUsesWith(
+ Builder.getFolder().CreateBitCast(Fn, FnEntry->getType())
+ );
changeLLVMValue(FnEntry, Fn);
FnEntry->eraseFromParent();
}
@@ -652,7 +653,9 @@
// Handle noinline Functions
if (lookup_attribute ("noinline", DECL_ATTRIBUTES (FnDecl))) {
const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
- AttributeNoinlineFunctions.push_back(ConstantExpr::getBitCast(Fn,SBP));
+ AttributeNoinlineFunctions.push_back(
+ Builder.getFolder().CreateBitCast(Fn, SBP)
+ );
}
// Handle annotate attributes
@@ -1151,32 +1154,14 @@
/// CastToType - Cast the specified value to the specified type if it is
/// not already that type.
Value *TreeToLLVM::CastToType(unsigned opcode, Value *V, const Type* Ty) {
- // Eliminate useless casts of a type to itself.
- if (V->getType() == Ty)
- return V;
-
- // If this is a simple constant operand, fold it now. If it is a constant
- // expr operand, fold it below.
- if (Constant *C = dyn_cast(V))
- if (!isa(C))
- return ConstantExpr::getCast(Instruction::CastOps(opcode), C, Ty);
-
// Handle 'trunc (zext i1 X to T2) to i1' as X, because this occurs all over
// the place.
if (ZExtInst *CI = dyn_cast(V))
if (Ty == Type::Int1Ty && CI->getOperand(0)->getType() == Type::Int1Ty)
return CI->getOperand(0);
- // Do an end-run around the builder's folding logic.
- // TODO: introduce a new builder class that does target specific folding.
- Value *Result = Builder.Insert(CastInst::Create(Instruction::CastOps(opcode),
- V, Ty, V->getNameStart()));
-
- // If this is a constantexpr, fold the instruction with
- // ConstantFoldInstruction to allow TargetData-driven folding to occur.
- if (isa(V))
- Result = ConstantFoldInstruction(cast(Result), &TD);
-
- return Result;
+
+ return Builder.CreateCast(Instruction::CastOps(opcode), V, Ty,
+ V->getNameStart());
}
/// CastToAnyType - Cast the specified value to the specified type making no
@@ -1296,7 +1281,7 @@
/// CopyAggregate - Recursively traverse the potientially aggregate src/dest
/// ptrs, copying all of the elements.
static void CopyAggregate(MemRef DestLoc, MemRef SrcLoc,
- IRBuilder<> &Builder, tree gccType) {
+ LLVMBuilder &Builder, tree gccType){
assert(DestLoc.Ptr->getType() == SrcLoc.Ptr->getType() &&
"Cannot copy between two pointers of different type!");
const Type *ElTy =
@@ -1386,7 +1371,7 @@
/// ZeroAggregate - Recursively traverse the potentially aggregate DestLoc,
/// zero'ing all of the elements.
-static void ZeroAggregate(MemRef DestLoc, IRBuilder<> &Builder) {
+static void ZeroAggregate(MemRef DestLoc, LLVMBuilder &Builder) {
const Type *ElTy =
cast(DestLoc.Ptr->getType())->getElementType();
if (ElTy->isSingleValueType()) {
@@ -1521,7 +1506,7 @@
Constant *lineNo = ConstantInt::get(Type::Int32Ty, DECL_SOURCE_LINE(decl));
Constant *file = ConvertMetadataStringToGV(DECL_SOURCE_FILE(decl));
const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
- file = ConstantExpr::getBitCast(file, SBP);
+ file = Builder.getFolder().CreateBitCast(file, SBP);
// There may be multiple annotate attributes. Pass return of lookup_attr
// to successive lookups.
@@ -2014,7 +1999,8 @@
tree catch_all_type = lang_eh_catch_all();
if (catch_all_type == NULL_TREE)
// Use a C++ style null catch-all object.
- Catch_All = Constant::getNullValue(PointerType::getUnqual(Type::Int8Ty));
+ Catch_All =
+ Constant::getNullValue(PointerType::getUnqual(Type::Int8Ty));
else
// This language has a type that catches all others.
Catch_All = Emit(catch_all_type, 0);
@@ -2251,8 +2237,8 @@
unsigned BitsInVal = ThisLastBitPlusOne - ThisFirstBit;
unsigned FirstBitInVal = ThisFirstBit % ValSizeInBits;
- // If this target has bitfields laid out in big-endian order, invert the bit
- // in the word if needed.
+ // If this target has bitfields laid out in big-endian order, invert the
+ // bit in the word if needed.
if (BITS_BIG_ENDIAN)
FirstBitInVal = ValSizeInBits-FirstBitInVal-BitsInVal;
@@ -2261,8 +2247,8 @@
// expression.
if (FirstBitInVal+BitsInVal != ValSizeInBits) {
- Value *ShAmt = ConstantInt::get(ValTy,
- ValSizeInBits-(FirstBitInVal+BitsInVal));
+ Value *ShAmt = ConstantInt::get(ValTy, ValSizeInBits -
+ (FirstBitInVal+BitsInVal));
Val = Builder.CreateShl(Val, ShAmt);
}
@@ -2355,7 +2341,7 @@
static Value *llvm_load_scalar_argument(Value *L,
const llvm::Type *LLVMTy,
unsigned RealSize,
- IRBuilder<> &Builder) {
+ LLVMBuilder &Builder) {
assert (0 && "The target should override this routine!");
return NULL;
}
@@ -2375,7 +2361,7 @@
const FunctionType *FTy;
const MemRef *DestLoc;
bool useReturnSlot;
- IRBuilder<> &Builder;
+ LLVMBuilder &Builder;
Value *TheValue;
MemRef RetBuf;
bool isShadowRet;
@@ -2386,7 +2372,7 @@
const FunctionType *FnTy,
const MemRef *destloc,
bool ReturnSlotOpt,
- IRBuilder<> &b)
+ LLVMBuilder &b)
: CallOperands(ops), FTy(FnTy), DestLoc(destloc),
useReturnSlot(ReturnSlotOpt), Builder(b), isShadowRet(false),
isAggrRet(false), Offset(0) { }
@@ -2552,8 +2538,9 @@
CallOperands.push_back(Loc);
}
- /// HandleByInvisibleReferenceArgument - This callback is invoked if a pointer
- /// (of type PtrTy) to the argument is passed rather than the argument itself.
+ /// HandleByInvisibleReferenceArgument - This callback is invoked if a
+ /// pointer (of type PtrTy) to the argument is passed rather than the
+ /// argument itself.
void HandleByInvisibleReferenceArgument(const llvm::Type *PtrTy, tree type){
Value *Loc = getAddress();
Loc = Builder.CreateBitCast(Loc, PtrTy);
@@ -2943,13 +2930,13 @@
// be set in the result.
uint64_t MaskVal = ((1ULL << BitsInVal)-1) << FirstBitInVal;
Constant *Mask = ConstantInt::get(Type::Int64Ty, MaskVal);
- Mask = ConstantExpr::getTruncOrBitCast(Mask, ValTy);
+ Mask = Builder.getFolder().CreateTruncOrBitCast(Mask, ValTy);
if (FirstBitInVal+BitsInVal != ValSizeInBits)
NewVal = Builder.CreateAnd(NewVal, Mask);
// Next, mask out the bits this bit-field should include from the old value.
- Mask = ConstantExpr::getNot(Mask);
+ Mask = Builder.getFolder().CreateNot(Mask);
OldVal = Builder.CreateAnd(OldVal, Mask);
// Finally, merge the two together and store it.
@@ -3950,8 +3937,9 @@
// We should no longer consider mem constraints.
AllowsMem = false;
} else {
- // If we can simplify the constraint into something else, do so now. This
- // avoids LLVM having to know about all the (redundant) GCC constraints.
+ // If we can simplify the constraint into something else, do so now.
+ // This avoids LLVM having to know about all the (redundant) GCC
+ // constraints.
SimplifiedConstraint = CanonicalizeConstraint(Constraint+1);
}
} else {
@@ -3963,7 +3951,7 @@
cast(Dest.Ptr->getType())->getElementType();
assert(!Dest.isBitfield() && "Cannot assign into a bitfield!");
- if (!AllowsMem && DestValTy->isSingleValueType()) { // Reg dest -> asm return
+ if (!AllowsMem && DestValTy->isSingleValueType()) {// Reg dest -> asm return
StoreCallResultAddrs.push_back(Dest.Ptr);
ConstraintStr += ",=";
ConstraintStr += SimplifiedConstraint;
@@ -4467,7 +4455,7 @@
Constant *lineNo = ConstantInt::get(Type::Int32Ty, locus.line);
Constant *file = ConvertMetadataStringToGV(locus.file);
const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
- file = ConstantExpr::getBitCast(file, SBP);
+ file = Builder.getFolder().CreateBitCast(file, SBP);
// Get arguments.
tree arglist = TREE_OPERAND(exp, 1);
@@ -4483,7 +4471,7 @@
assert(Ty && "llvm.annotation arg type may not be null");
Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
- Intrinsic::annotation,
+ Intrinsic::annotation,
&Ty,
1),
Args.begin(), Args.end());
@@ -5067,8 +5055,8 @@
" using zero");
ReadWrite = 0;
} else {
- ReadWrite = ConstantExpr::getIntegerCast(cast(ReadWrite),
- Type::Int32Ty, false);
+ ReadWrite = Builder.getFolder().CreateIntCast(cast(ReadWrite),
+ Type::Int32Ty, false);
}
if (TREE_CHAIN(TREE_CHAIN(arglist))) {
@@ -5080,8 +5068,8 @@
warning(0, "invalid third argument to %<__builtin_prefetch%>; using 3");
Locality = 0;
} else {
- Locality = ConstantExpr::getIntegerCast(cast(Locality),
- Type::Int32Ty, false);
+ Locality = Builder.getFolder().CreateIntCast(cast(Locality),
+ Type::Int32Ty, false);
}
}
}
@@ -5741,7 +5729,7 @@
TypeSize = CastToUIntType(TypeSize, IntPtrTy);
IndexVal = Builder.CreateMul(IndexVal, TypeSize);
Value *Ptr = Builder.CreateGEP(ArrayAddr, IndexVal);
- return BitCastToType(Ptr, PointerType::getUnqual(ConvertType(TREE_TYPE(exp))));
+ return BitCastToType(Ptr,PointerType::getUnqual(ConvertType(TREE_TYPE(exp))));
}
/// getFieldOffsetInBits - Return the offset (in bits) of a FIELD_DECL in a
@@ -5965,7 +5953,7 @@
if (BitStart == 0 && BitSize == ValueSizeInBits)
return LValue(BitCastToType(Ptr.Ptr, PointerType::getUnqual(ValTy)));
- return LValue(BitCastToType(Ptr.Ptr, PointerType::getUnqual(ValTy)), BitStart,
+ return LValue(BitCastToType(Ptr.Ptr, PointerType::getUnqual(ValTy)), BitStart,
BitSize);
}
@@ -6110,7 +6098,7 @@
case CONSTRUCTOR: return ConvertCONSTRUCTOR(exp);
case VIEW_CONVERT_EXPR: return Convert(TREE_OPERAND(exp, 0));
case ADDR_EXPR:
- return ConstantExpr::getBitCast(EmitLV(TREE_OPERAND(exp, 0)),
+ return TheFolder->CreateBitCast(EmitLV(TREE_OPERAND(exp, 0)),
ConvertType(TREE_TYPE(exp)));
}
}
@@ -6127,7 +6115,7 @@
// so we need a generalized cast here
Instruction::CastOps opcode = CastInst::getCastOpcode(C, false, Ty,
!TYPE_UNSIGNED(TREE_TYPE(exp)));
- return ConstantExpr::getCast(opcode, C, Ty);
+ return TheFolder->CreateCast(opcode, C, Ty);
}
Constant *TreeConstantToLLVM::ConvertREAL_CST(tree exp) {
@@ -6279,7 +6267,7 @@
// Elt and Ty can be integer, float or pointer here: need generalized cast
Instruction::CastOps opcode = CastInst::getCastOpcode(Elt, EltIsSigned,
Ty, TyIsSigned);
- return ConstantExpr::getCast(opcode, Elt, Ty);
+ return TheFolder->CreateCast(opcode, Elt, Ty);
}
Constant *TreeConstantToLLVM::ConvertCONVERT_EXPR(tree exp) {
@@ -6289,7 +6277,7 @@
bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
Instruction::CastOps opcode = CastInst::getCastOpcode(Elt, EltIsSigned, Ty,
TyIsSigned);
- return ConstantExpr::getCast(opcode, Elt, Ty);
+ return TheFolder->CreateCast(opcode, Elt, Ty);
}
Constant *TreeConstantToLLVM::ConvertBinOp_CST(tree exp) {
@@ -6301,22 +6289,22 @@
if (isa(LHS->getType())) {
const Type *IntPtrTy = getTargetData().getIntPtrType();
opcode = CastInst::getCastOpcode(LHS, LHSIsSigned, IntPtrTy, false);
- LHS = ConstantExpr::getCast(opcode, LHS, IntPtrTy);
+ LHS = TheFolder->CreateCast(opcode, LHS, IntPtrTy);
opcode = CastInst::getCastOpcode(RHS, RHSIsSigned, IntPtrTy, false);
- RHS = ConstantExpr::getCast(opcode, RHS, IntPtrTy);
+ RHS = TheFolder->CreateCast(opcode, RHS, IntPtrTy);
}
Constant *Result;
switch (TREE_CODE(exp)) {
default: assert(0 && "Unexpected case!");
- case PLUS_EXPR: Result = ConstantExpr::getAdd(LHS, RHS); break;
- case MINUS_EXPR: Result = ConstantExpr::getSub(LHS, RHS); break;
+ case PLUS_EXPR: Result = TheFolder->CreateAdd(LHS, RHS); break;
+ case MINUS_EXPR: Result = TheFolder->CreateSub(LHS, RHS); break;
}
const Type *Ty = ConvertType(TREE_TYPE(exp));
bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp));
opcode = CastInst::getCastOpcode(Result, LHSIsSigned, Ty, TyIsSigned);
- return ConstantExpr::getCast(opcode, Result, Ty);
+ return TheFolder->CreateCast(opcode, Result, Ty);
}
Constant *TreeConstantToLLVM::ConvertCONSTRUCTOR(tree exp) {
@@ -6483,7 +6471,7 @@
// Insert the new value into the field and return it.
uint64_t NewVal = (ExistingVal & ~FieldMask) | ValToInsert;
- return ConstantExpr::getTruncOrBitCast(ConstantInt::get(Type::Int64Ty,
+ return TheFolder->CreateTruncOrBitCast(ConstantInt::get(Type::Int64Ty,
NewVal), FieldTy);
} else {
// Otherwise, this is initializing part of an array of bytes. Recursively
@@ -6547,7 +6535,8 @@
// is used to access two struct fields and llvm field is represented
// as an array of bytes.
for (; i < Elts.size(); ++i)
- Elts[i] = ConstantInt::get((cast(FieldTy))->getElementType(), 0);
+ Elts[i] = ConstantInt::get((cast(FieldTy))->getElementType(),
+ 0);
return ConstantArray::get(cast(FieldTy), Elts);
}
@@ -6892,7 +6881,7 @@
BasicBlock *BB = getLabelDeclBlock(exp);
Constant *C = TheTreeToLLVM->getIndirectGotoBlockNumber(BB);
- return ConstantExpr::getIntToPtr(C, PointerType::getUnqual(Type::Int8Ty));
+ return TheFolder->CreateIntToPtr(C, PointerType::getUnqual(Type::Int8Ty));
}
Constant *TreeConstantToLLVM::EmitLV_COMPLEX_CST(tree exp) {
@@ -6972,22 +6961,15 @@
const Type *IntPtrTy = getTargetData().getIntPtrType();
if (IndexVal->getType() != IntPtrTy)
- IndexVal = ConstantExpr::getIntegerCast(IndexVal, IntPtrTy,
- !TYPE_UNSIGNED(IndexType));
+ IndexVal = TheFolder->CreateIntCast(IndexVal, IntPtrTy,
+ !TYPE_UNSIGNED(IndexType));
std::vector Idx;
if (isArrayCompatible(ArrayType))
Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
Idx.push_back(IndexVal);
- Constant *ArrayRef = ConstantExpr::getGetElementPtr(ArrayAddr, &Idx[0],
- Idx.size());
-
- if (ConstantExpr *CE = dyn_cast(ArrayRef))
- if (Constant *C = ConstantFoldConstantExpression(CE, &getTargetData()))
- return C;
-
- return ArrayRef;
+ return TheFolder->CreateGetElementPtr(ArrayAddr, &Idx[0], Idx.size());
}
Constant *TreeConstantToLLVM::EmitLV_COMPONENT_REF(tree exp) {
@@ -6999,7 +6981,7 @@
tree FieldDecl = TREE_OPERAND(exp, 1);
- StructAddrLV = ConstantExpr::getBitCast(StructAddrLV,
+ StructAddrLV = TheFolder->CreateBitCast(StructAddrLV,
PointerType::getUnqual(StructTy));
const Type *FieldTy = ConvertType(getDeclaredType(FieldDecl));
@@ -7020,7 +7002,7 @@
Constant::getNullValue(Type::Int32Ty),
ConstantInt::get(Type::Int32Ty, MemberIndex)
};
- FieldPtr = ConstantExpr::getGetElementPtr(StructAddrLV, Ops+1, 2);
+ FieldPtr = TheFolder->CreateGetElementPtr(StructAddrLV, Ops+1, 2);
FieldPtr = ConstantFoldInstOperands(Instruction::GetElementPtr,
FieldPtr->getType(), Ops,
@@ -7034,13 +7016,13 @@
}
} else {
Constant *Offset = Convert(field_offset);
- Constant *Ptr = ConstantExpr::getPtrToInt(StructAddrLV, Offset->getType());
- Ptr = ConstantExpr::getAdd(Ptr, Offset);
- FieldPtr = ConstantExpr::getIntToPtr(Ptr, PointerType::getUnqual(FieldTy));
+ Constant *Ptr = TheFolder->CreatePtrToInt(StructAddrLV, Offset->getType());
+ Ptr = TheFolder->CreateAdd(Ptr, Offset);
+ FieldPtr = TheFolder->CreateIntToPtr(Ptr, PointerType::getUnqual(FieldTy));
}
if (isBitfield(FieldDecl))
- FieldPtr = ConstantExpr::getBitCast(FieldPtr,
+ FieldPtr = TheFolder->CreateBitCast(FieldPtr,
PointerType::getUnqual(FieldTy));
assert(BitStart == 0 &&
@@ -7049,4 +7031,3 @@
}
/* LLVM LOCAL end (ENTIRE FILE!) */
-
Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Mon Aug 11 10:33:51 2008
@@ -232,7 +232,7 @@
/// getCastValueFor - Return a llvm representation for a given debug information
/// descriptor cast to an empty struct pointer.
Value *DebugInfo::getCastValueFor(DebugInfoDesc *DD) {
- return ConstantExpr::getBitCast(SR.Serialize(DD), SR.getEmptyStructPtrType());
+ return TheFolder->CreateBitCast(SR.Serialize(DD), SR.getEmptyStructPtrType());
}
/// EmitFunctionStart - Constructs the debug code for entering a function -
Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=54641&r1=54640&r2=54641&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Mon Aug 11 10:33:51 2008
@@ -39,6 +39,7 @@
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Support/Streams.h"
+#include "llvm/Support/TargetFolder.h"
extern "C" {
#include "llvm.h"
@@ -68,6 +69,8 @@
}
using namespace llvm;
+typedef IRBuilder LLVMBuilder;
+
/// TheModule - This is the current global module that we are compiling into.
///
extern llvm::Module *TheModule;
@@ -80,6 +83,9 @@
///
extern llvm::TargetMachine *TheTarget;
+/// TheFolder - The constant folder to use.
+extern TargetFolder *TheFolder;
+
/// getTargetData - Return the current TargetData object from TheTarget.
const TargetData &getTargetData();
@@ -281,7 +287,7 @@
/// Builder - Instruction creator, the location to insert into is always the
/// same as &Fn->back().
- IRBuilder<> Builder;
+ LLVMBuilder Builder;
// AllocaInsertionPoint - Place to insert alloca instructions. Lazily created
// and managed by CreateTemporary.
From natebegeman at mac.com Mon Aug 11 12:36:31 2008
From: natebegeman at mac.com (Nate Begeman)
Date: Mon, 11 Aug 2008 17:36:31 -0000
Subject: [llvm-commits] [llvm] r54644 - in /llvm/trunk/lib/Target/PowerPC:
PPCISelLowering.cpp PPCInstrFormats.td PPCInstrInfo.td README.txt
Message-ID: <200808111736.m7BHaV8m010078@zion.cs.uiuc.edu>
Author: sampo
Date: Mon Aug 11 12:36:31 2008
New Revision: 54644
URL: http://llvm.org/viewvc/llvm-project?rev=54644&view=rev
Log:
Implement ISD::TRAP support on PPC
Modified:
llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/trunk/lib/Target/PowerPC/PPCInstrFormats.td
llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td
llvm/trunk/lib/Target/PowerPC/README.txt
Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=54644&r1=54643&r2=54644&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Mon Aug 11 12:36:31 2008
@@ -183,9 +183,12 @@
setOperationAction(ISD::ConstantPool, MVT::i64, Custom);
setOperationAction(ISD::JumpTable, MVT::i64, Custom);
- // RET must be custom lowered, to meet ABI requirements
+ // RET must be custom lowered, to meet ABI requirements.
setOperationAction(ISD::RET , MVT::Other, Custom);
+ // TRAP is legal.
+ setOperationAction(ISD::TRAP, MVT::Other, Legal);
+
// VASTART needs to be custom lowered to use the VarArgsFrameIndex
setOperationAction(ISD::VASTART , MVT::Other, Custom);
Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrFormats.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrFormats.td?rev=54644&r1=54643&r2=54644&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCInstrFormats.td (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCInstrFormats.td Mon Aug 11 12:36:31 2008
@@ -298,6 +298,17 @@
let Inst{31} = 0;
}
+class XForm_24 opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
+ InstrItinClass itin, list pattern>
+ : I {
+ let Pattern = pattern;
+ let Inst{6-10} = 31;
+ let Inst{11-15} = 0;
+ let Inst{16-20} = 0;
+ let Inst{21-30} = xo;
+ let Inst{31} = 0;
+}
+
class XForm_25 opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
InstrItinClass itin, list pattern>
: XForm_base_r3xo {
Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td?rev=54644&r1=54643&r2=54644&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td Mon Aug 11 12:36:31 2008
@@ -575,6 +575,9 @@
[(PPCstcx GPRC:$rS, xoaddr:$dst)]>,
isDOT;
+let isBarrier = 1, hasCtrlDep = 1 in
+def TRAP : XForm_24<31, 4, (outs), (ins), "trap", LdStGeneral, [(trap)]>;
+
//===----------------------------------------------------------------------===//
// PPC32 Load Instructions.
//
Modified: llvm/trunk/lib/Target/PowerPC/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/README.txt?rev=54644&r1=54643&r2=54644&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/README.txt (original)
+++ llvm/trunk/lib/Target/PowerPC/README.txt Mon Aug 11 12:36:31 2008
@@ -3,7 +3,6 @@
TODO:
* gpr0 allocation
* implement do-loop -> bdnz transform
-* Implement __builtin_trap (ISD::TRAP) as 'tw 31, 0, 0' aka 'trap'.
* lmw/stmw pass a la arm load store optimizer for prolog/epilog
===-------------------------------------------------------------------------===
From gohman at apple.com Mon Aug 11 13:27:03 2008
From: gohman at apple.com (Dan Gohman)
Date: Mon, 11 Aug 2008 18:27:03 -0000
Subject: [llvm-commits] [llvm] r54646 - in /llvm/trunk:
lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/pr2656.ll
Message-ID: <200808111827.m7BIR398011858@zion.cs.uiuc.edu>
Author: djg
Date: Mon Aug 11 13:27:03 2008
New Revision: 54646
URL: http://llvm.org/viewvc/llvm-project?rev=54646&view=rev
Log:
Take the FrameOffset into account when computing the alignment
of stack objects. This fixes PR2656.
Added:
llvm/trunk/test/CodeGen/X86/pr2656.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=54646&r1=54645&r2=54646&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Aug 11 13:27:03 2008
@@ -4378,7 +4378,7 @@
// FIXME: Handle FI+CST.
const MachineFrameInfo &MFI = *DAG.getMachineFunction().getFrameInfo();
if (MFI.isFixedObjectIndex(FrameIdx)) {
- int64_t ObjectOffset = MFI.getObjectOffset(FrameIdx);
+ int64_t ObjectOffset = MFI.getObjectOffset(FrameIdx) + FrameOffset;
// The alignment of the frame index can be determined from its offset from
// the incoming frame position. If the frame object is at offset 32 and
Added: llvm/trunk/test/CodeGen/X86/pr2656.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr2656.ll?rev=54646&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr2656.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr2656.ll Mon Aug 11 13:27:03 2008
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | llc -march=x86 | grep {xorps.\*sp} | count 1
+; PR2656
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
+target triple = "i686-apple-darwin9.4.0"
+ %struct.anon = type <{ float, float }>
+ at .str = internal constant [17 x i8] c"pt: %.0f, %.0f\0A\00\00" ; <[17 x i8]*> [#uses=1]
+
+define void @foo(%struct.anon* byval %p) nounwind {
+entry:
+ %tmp = getelementptr %struct.anon* %p, i32 0, i32 0 ; [#uses=1]
+ %tmp1 = load float* %tmp ; [#uses=1]
+ %tmp2 = getelementptr %struct.anon* %p, i32 0, i32 1 ; [#uses=1]
+ %tmp3 = load float* %tmp2 ; [#uses=1]
+ %neg = sub float -0.000000e+00, %tmp1 ; [#uses=1]
+ %conv = fpext float %neg to double ; [#uses=1]
+ %neg4 = sub float -0.000000e+00, %tmp3 ; [#uses=1]
+ %conv5 = fpext float %neg4 to double ; [#uses=1]
+ %call = call i32 (...)* @printf( i8* getelementptr ([17 x i8]* @.str, i32 0, i32 0), double %conv, double %conv5 ) ; [#uses=0]
+ ret void
+}
+
+declare i32 @printf(...)
From bruno.cardoso at gmail.com Mon Aug 11 14:19:55 2008
From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes)
Date: Mon, 11 Aug 2008 16:19:55 -0300
Subject: [llvm-commits] legalize types, fneg support
Message-ID: <275e64e40808111219o3c01d05anbae54ddb7c30126a@mail.gmail.com>
Patch to Soften float fneg results, Mips need this (while in single
float only mode) for f64 fneg results.
--
Bruno Cardoso Lopes
http://www.brunocardoso.cc
"When faced with untenable alternatives, you
should consider your imperative."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: legalize-types-fneg.patch
Type: application/octet-stream
Size: 1867 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080811/90263cd8/attachment.obj
From gohman at apple.com Mon Aug 11 15:10:43 2008
From: gohman at apple.com (Dan Gohman)
Date: Mon, 11 Aug 2008 20:10:43 -0000
Subject: [llvm-commits] [llvm] r54648 -
/llvm/trunk/test/CodeGen/X86/extractps.ll
Message-ID: <200808112010.m7BKAhWM015178@zion.cs.uiuc.edu>
Author: djg
Date: Mon Aug 11 15:10:41 2008
New Revision: 54648
URL: http://llvm.org/viewvc/llvm-project?rev=54648&view=rev
Log:
Improve the grep commands for this test to be tolerant of ABI
differences, and to be more specific.
Modified:
llvm/trunk/test/CodeGen/X86/extractps.ll
Modified: llvm/trunk/test/CodeGen/X86/extractps.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/extractps.ll?rev=54648&r1=54647&r2=54648&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/extractps.ll (original)
+++ llvm/trunk/test/CodeGen/X86/extractps.ll Mon Aug 11 15:10:41 2008
@@ -1,4 +1,7 @@
-; RUN: llvm-as < %s | llc -mcpu=penryn | grep mov | count 1
+; RUN: llvm-as < %s | llc -mcpu=penryn > %t
+; not grep movd %t
+; not grep movss %t
+; grep {extractps \\$0, %xmm0, } %t
; PR2647
external global float, align 16 ; :0 [#uses=2]
From criswell at uiuc.edu Mon Aug 11 15:41:04 2008
From: criswell at uiuc.edu (John Criswell)
Date: Mon, 11 Aug 2008 20:41:04 -0000
Subject: [llvm-commits] [poolalloc] r54649 -
/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Message-ID: <200808112041.m7BKf4mc016157@zion.cs.uiuc.edu>
Author: criswell
Date: Mon Aug 11 15:41:03 2008
New Revision: 54649
URL: http://llvm.org/viewvc/llvm-project?rev=54649&view=rev
Log:
Don't pool allocate calls to realloc() and calloc() if no pool handle can be
found for the DSNode.
Modified:
poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=54649&r1=54648&r2=54649&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Mon Aug 11 15:41:03 2008
@@ -155,6 +155,10 @@
// Insert a call to poolalloc
Value *PH = getPoolHandle(I);
+
+ // Do not change the instruction into a poolalloc() call unless we have a
+ // real pool descriptor
+ if (PH == 0 || isa(PH)) return I;
Value* Opts[2] = {PH, Size};
Instruction *V = CallInst::Create(PAInfo.PoolAlloc, Opts, Opts + 2, Name, I);
@@ -363,6 +367,9 @@
Value *OldPtr = CS.getArgument(0);
Value *Size = CS.getArgument(1);
+ // Don't poolallocate if we have no pool handle
+ if (PH == 0 || isa(PH)) return;
+
if (Size->getType() != Type::Int32Ty)
Size = CastInst::createIntegerCast(Size, Type::Int32Ty, false, Size->getName(), I);
From clattner at apple.com Mon Aug 11 16:07:59 2008
From: clattner at apple.com (Chris Lattner)
Date: Mon, 11 Aug 2008 14:07:59 -0700
Subject: [llvm-commits] [llvm] r54640 - in
/llvm/trunk/include/llvm/Support: ConstantFolder.h
IRBuilder.h TargetFolder.h
In-Reply-To: <200808111529.m7BFTavc006237@zion.cs.uiuc.edu>
References: <200808111529.m7BFTavc006237@zion.cs.uiuc.edu>
Message-ID: <81AB5E44-EFA9-462E-B6B3-B35B696135DA@apple.com>
On Aug 11, 2008, at 8:29 AM, Duncan Sands wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=54640&view=rev
> Log:
> Make it possible to use different constant
> folding policies with IRBuilder. The default,
> provided by ConstantFolder, is to do minimal
> folding like now: what ConstantExpr provides.
> An alternative is to use TargetFolder, which
> uses target information to fold constants more.
Very nice Duncan, this is something we've needed for quite awhile.
This also gives us the ability to have an IRBuilder that does no
constant folding. With a folder that just returns the instructions.
> +++ llvm/trunk/include/llvm/Support/ConstantFolder.h Mon Aug 11
> 10:29:30 2008
> @@ -0,0 +1,175 @@
> +//===-- llvm/Support/ConstantFolder.h - Constant folding helper -*-
> C++ -*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open
> Source
> +// License. See LICENSE.TXT for details.
> +//
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +//
> +// This file defines the ConstantFolder class, which provides a set
> of methods
> +// for creating constants, with minimal folding.
Because of the name of this file, I expect a lot of people to go here
to look for the LLVM IR constant folding interfaces. Please document
that this file is designed for use with IRBuilder and point people to
the ConstantExpr::get* methods and libanalysis for simple constant
folding uses.
> +//====-- llvm/Support/TargetFolder.h - Constant folding helper -*- C
> ++ -*-====//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open
> Source
> +// License. See LICENSE.TXT for details.
> +//
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +//
> +// This file defines the TargetFolder class, which provides a set
> of methods
> +// for creating constants, with target dependent folding.
Likewise, please say that this is for use with IRBuilder.
> + //
> =
> =
> =--------------------------------------------------------------------
> ===//
> + // Compare Instructions
> + //
> =
> =
> =--------------------------------------------------------------------
> ===//
> +
> + Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS,
> Constant *RHS) const {
80 columns?
> + Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
> Constant *Idx)const {
> + return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx));
> + }
> +
> + Constant *CreateShuffleVector(Constant *V1, Constant *V2,
> Constant *Mask) const {
> + return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
> + }
80 cols.
Overall, very nice!
-Chris
From dpatel at apple.com Mon Aug 11 16:13:41 2008
From: dpatel at apple.com (Devang Patel)
Date: Mon, 11 Aug 2008 21:13:41 -0000
Subject: [llvm-commits] [llvm] r54650 - in /llvm/trunk:
include/llvm/PassManagers.h lib/VMCore/PassManager.cpp
Message-ID: <200808112113.m7BLDfEK017232@zion.cs.uiuc.edu>
Author: dpatel
Date: Mon Aug 11 16:13:39 2008
New Revision: 54650
URL: http://llvm.org/viewvc/llvm-project?rev=54650&view=rev
Log:
Keep track of analysis usage information for passes. Avoid invoking
getAnalysisUsage() repeatedly.
Modified:
llvm/trunk/include/llvm/PassManagers.h
llvm/trunk/lib/VMCore/PassManager.cpp
Modified: llvm/trunk/include/llvm/PassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=54650&r1=54649&r2=54650&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassManagers.h (original)
+++ llvm/trunk/include/llvm/PassManagers.h Mon Aug 11 16:13:39 2008
@@ -13,6 +13,7 @@
#include "llvm/PassManager.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/DenseMap.h"
#include
#include
@@ -172,6 +173,9 @@
/// then return NULL.
Pass *findAnalysisPass(AnalysisID AID);
+ /// Find analysis usage information for the pass P.
+ AnalysisUsage *findAnalysisUsage(Pass *P);
+
explicit PMTopLevelManager(enum TopLevelManagerType t);
virtual ~PMTopLevelManager();
@@ -221,6 +225,8 @@
/// Immutable passes are managed by top level manager.
std::vector ImmutablePasses;
+
+ DenseMap AnUsageMap;
};
Modified: llvm/trunk/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=54650&r1=54649&r2=54650&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassManager.cpp (original)
+++ llvm/trunk/lib/VMCore/PassManager.cpp Mon Aug 11 16:13:39 2008
@@ -421,6 +421,19 @@
LastUses.push_back(LUI->first);
}
+AnalysisUsage *PMTopLevelManager::findAnalysisUsage(Pass *P) {
+ AnalysisUsage *AnUsage = NULL;
+ DenseMap::iterator DMI = AnUsageMap.find(P);
+ if (DMI != AnUsageMap.end())
+ AnUsage = DMI->second;
+ else {
+ AnUsage = new AnalysisUsage();
+ P->getAnalysisUsage(*AnUsage);
+ AnUsageMap[P] = AnUsage;
+ }
+ return AnUsage;
+}
+
/// Schedule pass P for execution. Make sure that passes required by
/// P are run before P is run. Update analysis info maintained by
/// the manager. Remove dead passes. This is a recursive function.
@@ -439,9 +452,9 @@
P->getPassInfo()->isAnalysis() && findAnalysisPass(P->getPassInfo()))
return;
- AnalysisUsage AnUsage;
- P->getAnalysisUsage(AnUsage);
- const AnalysisUsage::VectorType &RequiredSet = AnUsage.getRequiredSet();
+ AnalysisUsage *AnUsage = findAnalysisUsage(P);
+
+ const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet();
for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(),
E = RequiredSet.end(); I != E; ++I) {
@@ -555,6 +568,13 @@
for (std::vector::iterator
I = ImmutablePasses.begin(), E = ImmutablePasses.end(); I != E; ++I)
delete *I;
+
+ for (DenseMap::iterator DMI = AnUsageMap.begin(),
+ DME = AnUsageMap.end(); DMI != DME; ++DMI) {
+ AnalysisUsage *AU = DMI->second;
+ delete AU;
+ }
+
}
//===----------------------------------------------------------------------===//
@@ -578,13 +598,12 @@
// passes managed by this manager
bool PMDataManager::preserveHigherLevelAnalysis(Pass *P) {
- AnalysisUsage AnUsage;
- P->getAnalysisUsage(AnUsage);
+ AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
- if (AnUsage.getPreservesAll())
+ if (AnUsage->getPreservesAll())
return true;
- const AnalysisUsage::VectorType &PreservedSet = AnUsage.getPreservedSet();
+ const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet();
for (std::vector::iterator I = HigherLevelAnalysis.begin(),
E = HigherLevelAnalysis.end(); I != E; ++I) {
Pass *P1 = *I;
@@ -604,9 +623,8 @@
#ifdef NDEBUG
return;
#endif
- AnalysisUsage AnUsage;
- P->getAnalysisUsage(AnUsage);
- const AnalysisUsage::VectorType &PreservedSet = AnUsage.getPreservedSet();
+ AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
+ const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet();
// Verify preserved analysis
for (AnalysisUsage::VectorType::const_iterator I = PreservedSet.begin(),
@@ -659,12 +677,11 @@
/// Remove Analysis not preserved by Pass P
void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
- AnalysisUsage AnUsage;
- P->getAnalysisUsage(AnUsage);
- if (AnUsage.getPreservesAll())
+ AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
+ if (AnUsage->getPreservesAll())
return;
- const AnalysisUsage::VectorType &PreservedSet = AnUsage.getPreservedSet();
+ const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet();
for (std::map::iterator I = AvailableAnalysis.begin(),
E = AvailableAnalysis.end(); I != E; ) {
std::map::iterator Info = I++;
@@ -820,9 +837,8 @@
void PMDataManager::collectRequiredAnalysis(SmallVector&RP,
SmallVector &RP_NotAvail,
Pass *P) {
- AnalysisUsage AnUsage;
- P->getAnalysisUsage(AnUsage);
- const AnalysisUsage::VectorType &RequiredSet = AnUsage.getRequiredSet();
+ AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
+ const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet();
for (AnalysisUsage::VectorType::const_iterator
I = RequiredSet.begin(), E = RequiredSet.end();
I != E; ++I) {
@@ -833,7 +849,7 @@
RP_NotAvail.push_back(AID);
}
- const AnalysisUsage::VectorType &IDs = AnUsage.getRequiredTransitiveSet();
+ const AnalysisUsage::VectorType &IDs = AnUsage->getRequiredTransitiveSet();
for (AnalysisUsage::VectorType::const_iterator I = IDs.begin(),
E = IDs.end(); I != E; ++I) {
AnalysisID AID = *I;
@@ -850,12 +866,11 @@
// implementations it needs.
//
void PMDataManager::initializeAnalysisImpl(Pass *P) {
- AnalysisUsage AnUsage;
- P->getAnalysisUsage(AnUsage);
-
+ AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P);
+
for (AnalysisUsage::VectorType::const_iterator
- I = AnUsage.getRequiredSet().begin(),
- E = AnUsage.getRequiredSet().end(); I != E; ++I) {
+ I = AnUsage->getRequiredSet().begin(),
+ E = AnUsage->getRequiredSet().end(); I != E; ++I) {
Pass *Impl = findAnalysisPass(*I, true);
if (Impl == 0)
// This may be analysis pass that is initialized on the fly.
From viridia at gmail.com Mon Aug 11 16:14:09 2008
From: viridia at gmail.com (Talin)
Date: Mon, 11 Aug 2008 14:14:09 -0700
Subject: [llvm-commits] DebugInfoBuilder
Message-ID:
OK I cleaned up the > 80 lines and renamed the methods as suggested.
With regards to the LLVMDebugVersion constants - I merely copied those from
MachineModuleInfo, I have no idea what the various version numbers
correspond to.
The problem with the debug version constants is that they are buried inside
of the CodeGen module, and I didn't want to create a dependency from the
Support module to the CodeGen module. Ideally, those constants should be
relocated to some header file where both CodeGen and Support can access
them. However, I don't know where that would be. So in the mean time I've
merely copied the definitions until a decision is made.
On the issue of ConstantStruct::get() and SmallVector: The way I tend to
design APIs is to take either a begin/end iterator or a begin/end pointer.
That allows you to use either a regular vector or a SmallVector with the
same API call. (Pointers are probably more correct, although I have noticed
that gcc lets you intermix pointers from differently-sized SmallVectors
without complaint.)
--
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080811/0e87c165/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIB.patch
Type: application/octet-stream
Size: 18042 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080811/0e87c165/attachment.obj
From sabre at nondot.org Mon Aug 11 17:06:06 2008
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 11 Aug 2008 22:06:06 -0000
Subject: [llvm-commits] [llvm] r54653 - in /llvm/trunk:
lib/Transforms/Scalar/InstructionCombining.cpp
test/Transforms/InstCombine/mul.ll
Message-ID: <200808112206.m7BM669t018954@zion.cs.uiuc.edu>
Author: lattner
Date: Mon Aug 11 17:06:05 2008
New Revision: 54653
URL: http://llvm.org/viewvc/llvm-project?rev=54653&view=rev
Log:
Implement support for simplifying vector comparisons by 0.0 and 1.0 like we
do for scalars. Patch contributed by Nicolas Capens
This also generalizes the previous xforms to work on long double, now that
isExactlyValue works for long double.
Modified:
llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/mul.ll
Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=54653&r1=54652&r2=54653&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Aug 11 17:06:05 2008
@@ -2480,10 +2480,17 @@
// "In IEEE floating point, x*1 is not equivalent to x for nans. However,
// ANSI says we can drop signals, so we can do this anyway." (from GCC)
- // We need a better interface for long double here.
- if (Op1->getType() == Type::FloatTy || Op1->getType() == Type::DoubleTy)
- if (Op1F->isExactlyValue(1.0))
- return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
+ if (Op1F->isExactlyValue(1.0))
+ return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
+ } else if (isa(Op1->getType())) {
+ if (isa(Op1))
+ return ReplaceInstUsesWith(I, Op1);
+
+ // As above, vector X*splat(1.0) -> X in all defined cases.
+ if (ConstantVector *Op1V = dyn_cast(Op1))
+ if (ConstantFP *F = dyn_cast_or_null(Op1V->getSplatValue()))
+ if (F->isExactlyValue(1.0))
+ return ReplaceInstUsesWith(I, Op0);
}
if (BinaryOperator *Op0I = dyn_cast(Op0))
@@ -11636,3 +11643,4 @@
return new InstCombiner();
}
+
Modified: llvm/trunk/test/Transforms/InstCombine/mul.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/mul.ll?rev=54653&r1=54652&r2=54653&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/mul.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/mul.ll Mon Aug 11 17:06:05 2008
@@ -1,7 +1,5 @@
; This test makes sure that mul instructions are properly eliminated.
-;
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep mul
-; END.
define i32 @test1(i32 %A) {
%B = mul i32 %A, 1 ; [#uses=1]
@@ -78,3 +76,18 @@
ret i32 %e
}
+; PR2642
+define internal void @test13(<4 x float>*) {
+ load <4 x float>* %0, align 1
+ mul <4 x float> %2, < float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00 >
+ store <4 x float> %3, <4 x float>* %0, align 1
+ ret void
+}
+
+define internal void @test14(<4 x float>*) {
+ load <4 x float>* %0, align 1
+ mul <4 x float> %2, zeroinitializer
+ store <4 x float> %3, <4 x float>* %0, align 1
+ ret void
+}
+
From sabre at nondot.org Mon Aug 11 18:39:51 2008
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 11 Aug 2008 23:39:51 -0000
Subject: [llvm-commits] [llvm] r54655 - in /llvm/trunk:
include/llvm/System/Path.h lib/System/Unix/Path.inc
lib/System/Win32/Path.inc
Message-ID: <200808112339.m7BNdpAI022274@zion.cs.uiuc.edu>
Author: lattner
Date: Mon Aug 11 18:39:47 2008
New Revision: 54655
URL: http://llvm.org/viewvc/llvm-project?rev=54655&view=rev
Log:
add a helper method to sys::Path for clang, patch by
Kovarththanan Rajaratnam!
Modified:
llvm/trunk/include/llvm/System/Path.h
llvm/trunk/lib/System/Unix/Path.inc
llvm/trunk/lib/System/Win32/Path.inc
Modified: llvm/trunk/include/llvm/System/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=54655&r1=54654&r2=54655&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Path.h (original)
+++ llvm/trunk/include/llvm/System/Path.h Mon Aug 11 18:39:47 2008
@@ -202,6 +202,12 @@
return *this;
}
+ /// Makes a copy of \p that to \p this.
+ /// @param \p that A std::string denoting the path
+ /// @returns \p this
+ /// @brief Assignment Operator
+ Path &operator=(const std::string &that);
+
/// Compares \p this Path with \p that Path for equality.
/// @returns true if \p this and \p that refer to the same thing.
/// @brief Equality Operator
Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=54655&r1=54654&r2=54655&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Mon Aug 11 18:39:47 2008
@@ -81,6 +81,12 @@
Path::Path(const char *StrStart, unsigned StrLen)
: path(StrStart, StrLen) {}
+Path&
+Path::operator=(const std::string &that) {
+ path = that;
+ return *this;
+}
+
bool
Path::isValid() const {
// Check some obvious things
Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=54655&r1=54654&r2=54655&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Mon Aug 11 18:39:47 2008
@@ -56,6 +56,13 @@
FlipBackSlashes(path);
}
+Path&
+Path::operator=(const std::string &that) {
+ path = that;
+ FlipBackSlashes(path);
+ return *this;
+}
+
bool
Path::isValid() const {
if (path.empty())
From dalej at apple.com Mon Aug 11 18:46:25 2008
From: dalej at apple.com (Dale Johannesen)
Date: Mon, 11 Aug 2008 23:46:25 -0000
Subject: [llvm-commits] [llvm] r54656 - in /llvm/trunk/lib:
ExecutionEngine/JIT/JITEmitter.cpp Target/X86/X86CodeEmitter.cpp
Target/X86/X86ISelDAGToDAG.cpp Target/X86/X86TargetMachine.cpp
Message-ID: <200808112346.m7BNkQ28022561@zion.cs.uiuc.edu>
Author: johannes
Date: Mon Aug 11 18:46:25 2008
New Revision: 54656
URL: http://llvm.org/viewvc/llvm-project?rev=54656&view=rev
Log:
Some fixes for x86-64 JIT. Make it use small code
model, except for external calls; this makes
addressing modes PC-relative. Incomplete.
The assertion at the top of Emitter::runOnMachineFunction
was obviously bogus (always true) so I removed it.
If someone knows what the correct test should be to cover
all the various targets, please fix.
Modified:
llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=54656&r1=54655&r2=54656&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon Aug 11 18:46:25 2008
@@ -920,9 +920,22 @@
Relocations.clear();
#ifndef NDEBUG
+ {
+ DOUT << std::hex;
+ int i;
+ unsigned char* q = FnStart;
+ for (i=1; q!=FnEnd; q++, i++) {
+ if (i%8==1)
+ DOUT << "0x" << (long)q << ": ";
+ DOUT<< (unsigned short)*q << " ";
+ if (i%8==0)
+ DOUT<<"\n";
+ }
+ DOUT << std::dec;
if (sys::hasDisassembler())
DOUT << "Disassembled code:\n"
<< sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
+ }
#endif
if (ExceptionHandling) {
uintptr_t ActualSize = 0;
Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=54656&r1=54655&r2=54656&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Mon Aug 11 18:46:25 2008
@@ -106,10 +106,7 @@
}
bool Emitter::runOnMachineFunction(MachineFunction &MF) {
- assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
- MF.getTarget().getRelocationModel() != Reloc::Static) &&
- "JIT relocation model must be set to static or default!");
-
+
MCE.setModuleInfo(&getAnalysis());
II = TM.getInstrInfo();
@@ -517,11 +514,16 @@
if (CurOp != NumOps) {
const MachineOperand &MO = MI.getOperand(CurOp++);
+DOUT << "RawFrm CurOp " << CurOp << "\n";
+DOUT << "isMachineBasicBlock " << MO.isMachineBasicBlock() << "\n";
+DOUT << "isGlobalAddress " << MO.isGlobalAddress() << "\n";
+DOUT << "isExternalSymbol " << MO.isExternalSymbol() << "\n";
+DOUT << "isImmediate " << MO.isImmediate() << "\n";
if (MO.isMachineBasicBlock()) {
emitPCRelativeBlockAddress(MO.getMBB());
} else if (MO.isGlobalAddress()) {
- bool NeedStub = (Is64BitMode && TM.getCodeModel() == CodeModel::Large)
- || Opcode == X86::TAILJMPd;
+ // Assume undefined functions may be outside the Small codespace.
+ bool NeedStub = Is64BitMode || Opcode == X86::TAILJMPd;
emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word,
0, 0, NeedStub);
} else if (MO.isExternalSymbol()) {
@@ -545,8 +547,6 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
- if (Opcode == X86::MOV64ri)
- rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
if (MO1.isGlobalAddress()) {
bool NeedStub = isa(MO1.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
@@ -617,8 +617,6 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
- if (Opcode == X86::MOV64ri32)
- rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO1.isGlobalAddress()) {
bool NeedStub = isa(MO1.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
@@ -654,8 +652,6 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
- if (Opcode == X86::MOV64mi32)
- rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO.isGlobalAddress()) {
bool NeedStub = isa(MO.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO.getGlobal());
Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=54656&r1=54655&r2=54656&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Aug 11 18:46:25 2008
@@ -35,6 +35,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Streams.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include
@@ -77,6 +78,23 @@
: BaseType(RegBase), isRIPRel(false), Scale(1), IndexReg(), Disp(0),
GV(0), CP(0), ES(0), JT(-1), Align(0) {
}
+ void dump() {
+ cerr << "X86ISelAddressMode " << this << "\n";
+ cerr << "Base.Reg "; if (Base.Reg.Val!=0) Base.Reg.Val->dump();
+ else cerr << "nul";
+ cerr << " Base.FrameIndex " << Base.FrameIndex << "\n";
+ cerr << "isRIPRel " << isRIPRel << " Scale" << Scale << "\n";
+ cerr << "IndexReg "; if (IndexReg.Val!=0) IndexReg.Val->dump();
+ else cerr << "nul";
+ cerr << " Disp " << Disp << "\n";
+ cerr << "GV "; if (GV) GV->dump();
+ else cerr << "nul";
+ cerr << " CP "; if (CP) CP->dump();
+ else cerr << "nul";
+ cerr << "\n";
+ cerr << "ES "; if (ES) cerr << ES; else cerr << "nul";
+ cerr << " JT" << JT << " Align" << Align << "\n";
+ }
};
}
@@ -676,6 +694,7 @@
/// addressing mode.
bool X86DAGToDAGISel::MatchAddress(SDValue N, X86ISelAddressMode &AM,
bool isRoot, unsigned Depth) {
+DOUT << "MatchAddress: "; DEBUG(AM.dump());
// Limit recursion.
if (Depth > 5)
return MatchAddressBase(N, AM, isRoot, Depth);
@@ -707,6 +726,9 @@
}
case X86ISD::Wrapper: {
+DOUT << "Wrapper: 64bit " << Subtarget->is64Bit();
+DOUT << " AM "; DEBUG(AM.dump()); DOUT << "\n";
+DOUT << "AlreadySelected " << AlreadySelected << "\n";
bool is64Bit = Subtarget->is64Bit();
// Under X86-64 non-small code model, GV (and friends) are 64-bits.
// Also, base and index reg must be 0 in order to use rip as base.
Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=54656&r1=54655&r2=54656&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Aug 11 18:46:25 2008
@@ -194,12 +194,14 @@
bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
bool DumpAsm, MachineCodeEmitter &MCE) {
// FIXME: Move this to TargetJITInfo!
- if (DefRelocModel == Reloc::Default)
+ // Do not override 64-bit setting made in X86TargetMachine().
+ if (DefRelocModel == Reloc::Default && !Subtarget.is64Bit())
setRelocationModel(Reloc::Static);
- // JIT cannot ensure globals are placed in the lower 4G of address.
+ // 64-bit JIT places everything in the same buffer except external functions.
+ // Use small code model but hack the call instruction for externals.
if (Subtarget.is64Bit())
- setCodeModel(CodeModel::Large);
+ setCodeModel(CodeModel::Small);
PM.add(createX86CodeEmitterPass(*this, MCE));
if (DumpAsm)
From isanbard at gmail.com Mon Aug 11 19:10:34 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Tue, 12 Aug 2008 00:10:34 -0000
Subject: [llvm-commits] [llvm] r54657 - /llvm/tags/Apple/llvmCore-2064/
Message-ID: <200808120010.m7C0AZ9C023415@zion.cs.uiuc.edu>
Author: void
Date: Mon Aug 11 19:10:32 2008
New Revision: 54657
URL: http://llvm.org/viewvc/llvm-project?rev=54657&view=rev
Log:
Creating llvmCore-2064 based on llvmCore-2062
Added:
llvm/tags/Apple/llvmCore-2064/
- copied from r54656, llvm/tags/Apple/llvmCore-2062/
From isanbard at gmail.com Mon Aug 11 19:11:05 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Tue, 12 Aug 2008 00:11:05 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r54658 -
/llvm-gcc-4.2/tags/Apple/llvmgcc42-2064/
Message-ID: <200808120011.m7C0B5Em023438@zion.cs.uiuc.edu>
Author: void
Date: Mon Aug 11 19:11:05 2008
New Revision: 54658
URL: http://llvm.org/viewvc/llvm-project?rev=54658&view=rev
Log:
Creating llvmgcc42-2064 based on llvmgcc42-2062
Added:
llvm-gcc-4.2/tags/Apple/llvmgcc42-2064/
- copied from r54657, llvm-gcc-4.2/tags/Apple/llvmgcc42-2062/
From isanbard at gmail.com Mon Aug 11 19:14:28 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Tue, 12 Aug 2008 00:14:28 -0000
Subject: [llvm-commits] [llvm] r54660 - in
/llvm/tags/Apple/llvmCore-2064/lib: ExecutionEngine/JIT/JITEmitter.cpp
Target/X86/X86CodeEmitter.cpp Target/X86/X86ISelDAGToDAG.cpp
Target/X86/X86TargetMachine.cpp
Message-ID: <200808120014.m7C0ES2O023552@zion.cs.uiuc.edu>
Author: void
Date: Mon Aug 11 19:14:28 2008
New Revision: 54660
URL: http://llvm.org/viewvc/llvm-project?rev=54660&view=rev
Log:
Pull r54656 into llvmCore-2064:
Some fixes for x86-64 JIT. Make it use small code
model, except for external calls; this makes
addressing modes PC-relative. Incomplete.
The assertion at the top of Emitter::runOnMachineFunction
was obviously bogus (always true) so I removed it.
If someone knows what the correct test should be to cover
all the various targets, please fix.
Modified:
llvm/tags/Apple/llvmCore-2064/lib/ExecutionEngine/JIT/JITEmitter.cpp
llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp
llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/tags/Apple/llvmCore-2064/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2064/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=54660&r1=54659&r2=54660&view=diff
==============================================================================
--- llvm/tags/Apple/llvmCore-2064/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/tags/Apple/llvmCore-2064/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon Aug 11 19:14:28 2008
@@ -920,9 +920,22 @@
Relocations.clear();
#ifndef NDEBUG
+ {
+ DOUT << std::hex;
+ int i;
+ unsigned char* q = FnStart;
+ for (i=1; q!=FnEnd; q++, i++) {
+ if (i%8==1)
+ DOUT << "0x" << (long)q << ": ";
+ DOUT<< (unsigned short)*q << " ";
+ if (i%8==0)
+ DOUT<<"\n";
+ }
+ DOUT << std::dec;
if (sys::hasDisassembler())
DOUT << "Disassembled code:\n"
<< sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
+ }
#endif
if (ExceptionHandling) {
uintptr_t ActualSize = 0;
Modified: llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp?rev=54660&r1=54659&r2=54660&view=diff
==============================================================================
--- llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp Mon Aug 11 19:14:28 2008
@@ -106,10 +106,7 @@
}
bool Emitter::runOnMachineFunction(MachineFunction &MF) {
- assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
- MF.getTarget().getRelocationModel() != Reloc::Static) &&
- "JIT relocation model must be set to static or default!");
-
+
MCE.setModuleInfo(&getAnalysis());
II = TM.getInstrInfo();
@@ -517,11 +514,16 @@
if (CurOp != NumOps) {
const MachineOperand &MO = MI.getOperand(CurOp++);
+DOUT << "RawFrm CurOp " << CurOp << "\n";
+DOUT << "isMachineBasicBlock " << MO.isMachineBasicBlock() << "\n";
+DOUT << "isGlobalAddress " << MO.isGlobalAddress() << "\n";
+DOUT << "isExternalSymbol " << MO.isExternalSymbol() << "\n";
+DOUT << "isImmediate " << MO.isImmediate() << "\n";
if (MO.isMachineBasicBlock()) {
emitPCRelativeBlockAddress(MO.getMBB());
} else if (MO.isGlobalAddress()) {
- bool NeedStub = (Is64BitMode && TM.getCodeModel() == CodeModel::Large)
- || Opcode == X86::TAILJMPd;
+ // Assume undefined functions may be outside the Small codespace.
+ bool NeedStub = Is64BitMode || Opcode == X86::TAILJMPd;
emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word,
0, 0, NeedStub);
} else if (MO.isExternalSymbol()) {
@@ -545,8 +547,6 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
- if (Opcode == X86::MOV64ri)
- rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
if (MO1.isGlobalAddress()) {
bool NeedStub = isa(MO1.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
@@ -617,8 +617,6 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
- if (Opcode == X86::MOV64ri32)
- rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO1.isGlobalAddress()) {
bool NeedStub = isa(MO1.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
@@ -654,8 +652,6 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
- if (Opcode == X86::MOV64mi32)
- rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO.isGlobalAddress()) {
bool NeedStub = isa(MO.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO.getGlobal());
Modified: llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=54660&r1=54659&r2=54660&view=diff
==============================================================================
--- llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Aug 11 19:14:28 2008
@@ -35,6 +35,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Streams.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include
@@ -77,6 +78,23 @@
: BaseType(RegBase), isRIPRel(false), Scale(1), IndexReg(), Disp(0),
GV(0), CP(0), ES(0), JT(-1), Align(0) {
}
+ void dump() {
+ cerr << "X86ISelAddressMode " << this << "\n";
+ cerr << "Base.Reg "; if (Base.Reg.Val!=0) Base.Reg.Val->dump();
+ else cerr << "nul";
+ cerr << " Base.FrameIndex " << Base.FrameIndex << "\n";
+ cerr << "isRIPRel " << isRIPRel << " Scale" << Scale << "\n";
+ cerr << "IndexReg "; if (IndexReg.Val!=0) IndexReg.Val->dump();
+ else cerr << "nul";
+ cerr << " Disp " << Disp << "\n";
+ cerr << "GV "; if (GV) GV->dump();
+ else cerr << "nul";
+ cerr << " CP "; if (CP) CP->dump();
+ else cerr << "nul";
+ cerr << "\n";
+ cerr << "ES "; if (ES) cerr << ES; else cerr << "nul";
+ cerr << " JT" << JT << " Align" << Align << "\n";
+ }
};
}
@@ -676,6 +694,7 @@
/// addressing mode.
bool X86DAGToDAGISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM,
bool isRoot, unsigned Depth) {
+DOUT << "MatchAddress: "; DEBUG(AM.dump());
// Limit recursion.
if (Depth > 5)
return MatchAddressBase(N, AM, isRoot, Depth);
@@ -707,6 +726,9 @@
}
case X86ISD::Wrapper: {
+DOUT << "Wrapper: 64bit " << Subtarget->is64Bit();
+DOUT << " AM "; DEBUG(AM.dump()); DOUT << "\n";
+DOUT << "AlreadySelected " << AlreadySelected << "\n";
bool is64Bit = Subtarget->is64Bit();
// Under X86-64 non-small code model, GV (and friends) are 64-bits.
// Also, base and index reg must be 0 in order to use rip as base.
Modified: llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86TargetMachine.cpp?rev=54660&r1=54659&r2=54660&view=diff
==============================================================================
--- llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86TargetMachine.cpp Mon Aug 11 19:14:28 2008
@@ -194,12 +194,14 @@
bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
bool DumpAsm, MachineCodeEmitter &MCE) {
// FIXME: Move this to TargetJITInfo!
- if (DefRelocModel == Reloc::Default)
+ // Do not override 64-bit setting made in X86TargetMachine().
+ if (DefRelocModel == Reloc::Default && !Subtarget.is64Bit())
setRelocationModel(Reloc::Static);
- // JIT cannot ensure globals are placed in the lower 4G of address.
+ // 64-bit JIT places everything in the same buffer except external functions.
+ // Use small code model but hack the call instruction for externals.
if (Subtarget.is64Bit())
- setCodeModel(CodeModel::Large);
+ setCodeModel(CodeModel::Small);
PM.add(createX86CodeEmitterPass(*this, MCE));
if (DumpAsm)
From viridia at gmail.com Mon Aug 11 19:25:24 2008
From: viridia at gmail.com (Talin)
Date: Mon, 11 Aug 2008 17:25:24 -0700
Subject: [llvm-commits] DebugInfoBuilder
Message-ID:
OK I cleaned up the > 80 lines and renamed the methods as suggested.
With regards to the LLVMDebugVersion constants - I merely copied those from
MachineModuleInfo, I have no idea what the various version numbers
correspond to.
The problem with the debug version constants is that they are buried inside
of the CodeGen module, and I didn't want to create a dependency from the
Support module to the CodeGen module. Ideally, those constants should be
relocated to some header file where both CodeGen and Support can access
them. However, I don't know where that would be. So in the mean time I've
merely copied the definitions until a decision is made.
On the issue of ConstantStruct::get() and SmallVector: The way I tend to
design APIs is to take either a begin/end iterator or a begin/end pointer.
That allows you to use either a regular vector or a SmallVector with the
same API call. (Pointers are probably more correct, although I have noticed
that gcc lets you intermix pointers from differently-sized SmallVectors
without complaint.)
--
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080811/f064e1c5/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIB.patch
Type: application/octet-stream
Size: 18042 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20080811/f064e1c5/attachment.obj
From dpatel at apple.com Mon Aug 11 19:26:16 2008
From: dpatel at apple.com (Devang Patel)
Date: Tue, 12 Aug 2008 00:26:16 -0000
Subject: [llvm-commits] [llvm] r54662 - in /llvm/trunk:
include/llvm/PassManagers.h lib/VMCore/PassManager.cpp
Message-ID: <200808120026.m7C0QHRh023900@zion.cs.uiuc.edu>
Author: dpatel
Date: Mon Aug 11 19:26:16 2008
New Revision: 54662
URL: http://llvm.org/viewvc/llvm-project?rev=54662&view=rev
Log:
Use DenseMap to keep track of last users.
Use inversed map for faster queries.
Modified:
llvm/trunk/include/llvm/PassManagers.h
llvm/trunk/lib/VMCore/PassManager.cpp
Modified: llvm/trunk/include/llvm/PassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=54662&r1=54661&r2=54662&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassManagers.h (original)
+++ llvm/trunk/include/llvm/PassManagers.h Mon Aug 11 19:26:16 2008
@@ -13,6 +13,7 @@
#include "llvm/PassManager.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/DenseMap.h"
#include
#include
@@ -221,7 +222,12 @@
// Map to keep track of last user of the analysis pass.
// LastUser->second is the last user of Lastuser->first.
- std::map LastUser;
+ DenseMap LastUser;
+
+ // Map to keep track of passes that are last used by a pass.
+ // This inverse map is initialized at PM->run() based on
+ // LastUser map.
+ DenseMap > InversedLastUser;
/// Immutable passes are managed by top level manager.
std::vector ImmutablePasses;
Modified: llvm/trunk/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=54662&r1=54661&r2=54662&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassManager.cpp (original)
+++ llvm/trunk/lib/VMCore/PassManager.cpp Mon Aug 11 19:26:16 2008
@@ -404,9 +404,11 @@
// If AP is the last user of other passes then make P last user of
// such passes.
- for (std::map::iterator LUI = LastUser.begin(),
+ for (DenseMap::iterator LUI = LastUser.begin(),
LUE = LastUser.end(); LUI != LUE; ++LUI) {
if (LUI->second == AP)
+ // DenseMap iterator is not invalidated here because
+ // this is just updating exisitng entry.
LastUser[LUI->first] = P;
}
}
@@ -414,11 +416,18 @@
/// Collect passes whose last user is P
void PMTopLevelManager::collectLastUses(SmallVector &LastUses,
- Pass *P) {
- for (std::map::iterator LUI = LastUser.begin(),
- LUE = LastUser.end(); LUI != LUE; ++LUI)
- if (LUI->second == P)
- LastUses.push_back(LUI->first);
+ Pass *P) {
+ DenseMap >::iterator DMI =
+ InversedLastUser.find(P);
+ if (DMI == InversedLastUser.end())
+ return;
+
+ SmallPtrSet &LU = DMI->second;
+ for (SmallPtrSet::iterator I = LU.begin(),
+ E = LU.end(); I != E; ++I) {
+ LastUses.push_back(*I);
+ }
+
}
AnalysisUsage *PMTopLevelManager::findAnalysisUsage(Pass *P) {
@@ -557,6 +566,19 @@
for (std::vector::iterator I = IndirectPassManagers.begin(),
E = IndirectPassManagers.end(); I != E; ++I)
(*I)->initializeAnalysisInfo();
+
+ for(DenseMap::iterator DMI = LastUser.begin(),
+ DME = LastUser.end(); DMI != DME; ++DMI) {
+ DenseMap >::iterator InvDMI =
+ InversedLastUser.find(DMI->second);
+ if (InvDMI != InversedLastUser.end()) {
+ SmallPtrSet &L = InvDMI->second;
+ L.insert(DMI->first);
+ } else {
+ SmallPtrSet L; L.insert(DMI->first);
+ InversedLastUser[DMI->second] = L;
+ }
+ }
}
/// Destructor
From isanbard at gmail.com Tue Aug 12 02:37:29 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Tue, 12 Aug 2008 07:37:29 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r54670 -
/llvm-gcc-4.2/trunk/gcc/libgcc2.c
Message-ID: <200808120737.m7C7bTQF004789@zion.cs.uiuc.edu>
Author: void
Date: Tue Aug 12 02:37:27 2008
New Revision: 54670
URL: http://llvm.org/viewvc/llvm-project?rev=54670&view=rev
Log:
Fix compilation of MingW by checking that winbase has not
already been included. Patch by Julien Lerouge!
Modified:
llvm-gcc-4.2/trunk/gcc/libgcc2.c
Modified: llvm-gcc-4.2/trunk/gcc/libgcc2.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/libgcc2.c?rev=54670&r1=54669&r2=54670&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/libgcc2.c (original)
+++ llvm-gcc-4.2/trunk/gcc/libgcc2.c Tue Aug 12 02:37:27 2008
@@ -2091,7 +2091,7 @@
#endif
}
-#ifdef __i386__
+#if defined(__i386__) && ! defined(_WINBASE_H)
extern int VirtualProtect (char *, int, int, int *) __attribute__((stdcall));
#endif
From baldrick at free.fr Tue Aug 12 04:43:17 2008
From: baldrick at free.fr (Duncan Sands)
Date: Tue, 12 Aug 2008 09:43:17 -0000
Subject: [llvm-commits] [llvm] r54676 - in /llvm/trunk/include/llvm/Support:
ConstantFolder.h TargetFolder.h
Message-ID: <200808120943.m7C9hIqM022326@zion.cs.uiuc.edu>
Author: baldrick
Date: Tue Aug 12 04:43:15 2008
New Revision: 54676
URL: http://llvm.org/viewvc/llvm-project?rev=54676&view=rev
Log:
Point people to ConstantExpr and ConstantFolding,
in case they get the wrong idea. Fit in 80 columns.
Modified:
llvm/trunk/include/llvm/Support/ConstantFolder.h
llvm/trunk/include/llvm/Support/TargetFolder.h
Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=54676&r1=54675&r2=54676&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ConstantFolder.h (original)
+++ llvm/trunk/include/llvm/Support/ConstantFolder.h Tue Aug 12 04:43:15 2008
@@ -7,8 +7,10 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the ConstantFolder class, which provides a set of methods
-// for creating constants, with minimal folding.
+// This file defines the ConstantFolder class, a helper for IRBuilder.
+// It provides IRBuilder with a set of methods for creating constants
+// with minimal folding. For general constant creation and folding,
+// use ConstantExpr and the routines in llvm/Analysis/ConstantFolding.h.
//
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/include/llvm/Support/TargetFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=54676&r1=54675&r2=54676&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TargetFolder.h (original)
+++ llvm/trunk/include/llvm/Support/TargetFolder.h Tue Aug 12 04:43:15 2008
@@ -7,9 +7,10 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the TargetFolder class, which provides a set of methods
-// for creating constants, with target dependent folding.
-//
+// This file defines the TargetFolder class, a helper for IRBuilder.
+// It provides IRBuilder with a set of methods for creating constants with
+// target dependent folding. For general constant creation and folding,
+// use ConstantExpr and the routines in llvm/Analysis/ConstantFolding.h.
//
//===----------------------------------------------------------------------===//
@@ -153,7 +154,8 @@
// Compare Instructions
//===--------------------------------------------------------------------===//
- Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const {
+ Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
return Fold(ConstantExpr::getCompare(P, LHS, RHS));
}
@@ -169,11 +171,13 @@
return Fold(ConstantExpr::getExtractElement(Vec, Idx));
}
- Constant *CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *Idx)const {
+ Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
+ Constant *Idx) const {
return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx));
}
- Constant *CreateShuffleVector(Constant *V1, Constant *V2, Constant *Mask) const {
+ Constant *CreateShuffleVector(Constant *V1, Constant *V2,
+ Constant *Mask) const {
return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
}
From baldrick at free.fr Tue Aug 12 04:43:48 2008
From: baldrick at free.fr (Duncan Sands)
Date: Tue, 12 Aug 2008 11:43:48 +0200
Subject: [llvm-commits] [llvm] r54640 - in
/llvm/trunk/include/llvm/Support: ConstantFolder.h
IRBuilder.h TargetFolder.h
In-Reply-To: <81AB5E44-EFA9-462E-B6B3-B35B696135DA@apple.com>
References: <200808111529.m7BFTavc006237@zion.cs.uiuc.edu>
<81AB5E44-EFA9-462E-B6B3-B35B696135DA@apple.com>
Message-ID: <200808121143.48741.baldrick@free.fr>
Hi Chris,
> Very nice Duncan, this is something we've needed for quite awhile.
> This also gives us the ability to have an IRBuilder that does no
> constant folding. With a folder that just returns the instructions.
yes, one of the advantages of using a template parameter is that
you can do this. I may add a NullBuilder tonight if I'm feeling
generous :)
...
> Because of the name of this file, I expect a lot of people to go here
> to look for the LLVM IR constant folding interfaces. Please document
> that this file is designed for use with IRBuilder and point people to
> the ConstantExpr::get* methods and libanalysis for simple constant
> folding uses.
...
> Likewise, please say that this is for use with IRBuilder.
Done.
> > + Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS,
> > Constant *RHS) const {
>
> 80 columns?
Sorry about that: it must have happened when I appended "const"
everywhere. Fixed.
Ciao,
Duncan.
From duncan.sands at math.u-psud.fr Tue Aug 12 05:20:29 2008
From: duncan.sands at math.u-psud.fr (Duncan Sands)
Date: Tue, 12 Aug 2008 12:20:29 +0200
Subject: [llvm-commits] [llvm] r54640 - in
/llvm/trunk/include/llvm/Support: ConstantFolder.h
IRBuilder.h TargetFolder.h
In-Reply-To: <81AB5E44-EFA9-462E-B6B3-B35B696135DA@apple.com>
References: <200808111529.m7BFTavc006237@zion.cs.uiuc.edu>
<81AB5E44-EFA9-462E-B6B3-B35B696135DA@apple.com>
Message-ID: <200808121220.29990.duncan.sands@math.u-psud.fr>
Hi Chris,
> Because of the name of this file, I expect a lot of people to go here
> to look for the LLVM IR constant folding interfaces. Please document
> that this file is designed for use with IRBuilder and point people to
> the ConstantExpr::get* methods and libanalysis for simple constant
> folding uses.
that said, llvm-gcc now also uses TargetFolder when directly creating
constants (eg: global variable initializers), and it's quite convenient
for that. This is the reason that TargetFolder has a few methods that
aren't needed by IRBuilder. I put the same extra methods in ConstantFolder,
so you can easily flip between ConstantFolder and TargetFolder in llvm-gcc.
Ciao,
Duncan.
From dpatel at apple.com Tue Aug 12 10:44:36 2008
From: dpatel at apple.com (Devang Patel)
Date: Tue, 12 Aug 2008 15:44:36 -0000
Subject: [llvm-commits] [llvm] r54685 - in /llvm/trunk:
include/llvm/PassManagers.h lib/VMCore/PassManager.cpp
Message-ID: <200808121544.m7CFib4l001258@zion.cs.uiuc.edu>
Author: dpatel
Date: Tue Aug 12 10:44:31 2008
New Revision: 54685
URL: http://llvm.org/viewvc/llvm-project?rev=54685&view=rev
Log:
Use SmallVector instead of std::vector
Modified:
llvm/trunk/include/llvm/PassManagers.h
llvm/trunk/lib/VMCore/PassManager.cpp
Modified: llvm/trunk/include/llvm/PassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=54685&r1=54684&r2=54685&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassManagers.h (original)
+++ llvm/trunk/include/llvm/PassManagers.h Tue Aug 12 10:44:31 2008
@@ -186,7 +186,7 @@
ImmutablePasses.push_back(P);
}
- inline std::vector& getImmutablePasses() {
+ inline SmallVector& getImmutablePasses() {
return ImmutablePasses;
}
@@ -212,13 +212,13 @@
protected:
/// Collection of pass managers
- std::vector PassManagers;
+ SmallVector PassManagers;
private:
/// Collection of pass managers that are not directly maintained
/// by this pass manager
- std::vector IndirectPassManagers;
+ SmallVector IndirectPassManagers;
// Map to keep track of last user of the analysis pass.
// LastUser->second is the last user of Lastuser->first.
@@ -230,7 +230,7 @@
DenseMap > InversedLastUser;
/// Immutable passes are managed by top level manager.
- std::vector ImmutablePasses;
+ SmallVector ImmutablePasses;
DenseMap AnUsageMap;
};
@@ -350,7 +350,7 @@
PMTopLevelManager *TPM;
// Collection of pass that are managed by this manager
- std::vector PassVector;
+ SmallVector PassVector;
// Collection of Analysis provided by Parent pass manager and
// used by current pass manager. At at time there can not be more
@@ -369,7 +369,7 @@
// Collection of higher level analysis used by the pass managed by
// this manager.
- std::vector HigherLevelAnalysis;
+ SmallVector HigherLevelAnalysis;
unsigned Depth;
};
Modified: llvm/trunk/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=54685&r1=54684&r2=54685&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassManager.cpp (original)
+++ llvm/trunk/lib/VMCore/PassManager.cpp Tue Aug 12 10:44:31 2008
@@ -491,18 +491,18 @@
Pass *P = NULL;
// Check pass managers
- for (std::vector::iterator I = PassManagers.begin(),
+ for (SmallVector::iterator I = PassManagers.begin(),
E = PassManagers.end(); P == NULL && I != E; ++I) {
PMDataManager *PMD = *I;
P = PMD->findAnalysisPass(AID, false);
}
// Check other pass managers
- for (std::vector::iterator I = IndirectPassManagers.begin(),
+ for (SmallVector::iterator I = IndirectPassManagers.begin(),
E = IndirectPassManagers.end(); P == NULL && I != E; ++I)
P = (*I)->findAnalysisPass(AID, false);
- for (std::vector::iterator I = ImmutablePasses.begin(),
+ for (SmallVector::iterator I = ImmutablePasses.begin(),
E = ImmutablePasses.end(); P == NULL && I != E; ++I) {
const PassInfo *PI = (*I)->getPassInfo();
if (PI == AID)
@@ -535,7 +535,7 @@
// (sometimes indirectly), but there's no inheritance relationship
// between PMDataManager and Pass, so we have to dynamic_cast to get
// from a PMDataManager* to a Pass*.
- for (std::vector::const_iterator I = PassManagers.begin(),
+ for (SmallVector::const_iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I)
dynamic_cast(*I)->dumpPassStructure(1);
}
@@ -546,7 +546,7 @@
return;
cerr << "Pass Arguments: ";
- for (std::vector::const_iterator I = PassManagers.begin(),
+ for (SmallVector::const_iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I) {
PMDataManager *PMD = *I;
PMD->dumpPassArguments();
@@ -556,14 +556,14 @@
void PMTopLevelManager::initializeAllAnalysisInfo() {
- for (std::vector::iterator I = PassManagers.begin(),
+ for (SmallVector::iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I) {
PMDataManager *PMD = *I;
PMD->initializeAnalysisInfo();
}
// Initailize other pass managers
- for (std::vector::iterator I = IndirectPassManagers.begin(),
+ for (SmallVector::iterator I = IndirectPassManagers.begin(),
E = IndirectPassManagers.end(); I != E; ++I)
(*I)->initializeAnalysisInfo();
@@ -583,11 +583,11 @@
/// Destructor
PMTopLevelManager::~PMTopLevelManager() {
- for (std::vector::iterator I = PassManagers.begin(),
+ for (SmallVector::iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I)
delete *I;
- for (std::vector::iterator
+ for (SmallVector::iterator
I = ImmutablePasses.begin(), E = ImmutablePasses.end(); I != E; ++I)
delete *I;
@@ -626,7 +626,7 @@
return true;
const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet();
- for (std::vector::iterator I = HigherLevelAnalysis.begin(),
+ for (SmallVector::iterator I = HigherLevelAnalysis.begin(),
E = HigherLevelAnalysis.end(); I != E; ++I) {
Pass *P1 = *I;
if (!dynamic_cast(P1) &&
@@ -940,7 +940,7 @@
}
void PMDataManager::dumpPassArguments() const {
- for(std::vector::const_iterator I = PassVector.begin(),
+ for(SmallVector::const_iterator I = PassVector.begin(),
E = PassVector.end(); I != E; ++I) {
if (PMDataManager *PMD = dynamic_cast(*I))
PMD->dumpPassArguments();
@@ -1054,7 +1054,7 @@
// Destructor
PMDataManager::~PMDataManager() {
- for (std::vector::iterator I = PassVector.begin(),
+ for (SmallVector::iterator I = PassVector.begin(),
E = PassVector.end(); I != E; ++I)
delete *I;
From criswell at uiuc.edu Tue Aug 12 11:35:30 2008
From: criswell at uiuc.edu (John Criswell)
Date: Tue, 12 Aug 2008 16:35:30 -0000
Subject: [llvm-commits] [poolalloc] r54686 -
/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Message-ID: <200808121635.m7CGZaY4003092@zion.cs.uiuc.edu>
Author: criswell
Date: Tue Aug 12 11:35:09 2008
New Revision: 54686
URL: http://llvm.org/viewvc/llvm-project?rev=54686&view=rev
Log:
Handle the situation where a function is casted before it is called.
Modified:
poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=54686&r1=54685&r2=54686&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Tue Aug 12 11:35:09 2008
@@ -757,6 +757,23 @@
// Add the rest of the arguments...
Args.insert(Args.end(), CS.arg_begin(), CS.arg_end());
+ //
+ // There are circumstances where a function is casted to another type and
+ // then called (que horible). We need to perform a similar cast if the
+ // type doesn't match the number of arguments.
+ //
+ if (Function * NewFunction = dyn_cast(NewCallee)) {
+ const FunctionType * NewCalleeType = NewFunction->getFunctionType();
+ if (NewCalleeType->getNumParams() != Args.size()) {
+ std::vector Types;
+ Type * FuncTy = FunctionType::get (NewCalleeType->getReturnType(),
+ Types,
+ true);
+ FuncTy = PointerType::getUnqual (FuncTy);
+ NewCallee = new BitCastInst (NewCallee, FuncTy, "", TheCall);
+ }
+ }
+
std::string Name = TheCall->getName(); TheCall->setName("");
if (InvokeInst *II = dyn_cast(TheCall)) {
From gohman at apple.com Tue Aug 12 12:01:06 2008
From: gohman at apple.com (Dan Gohman)
Date: Tue, 12 Aug 2008 10:01:06 -0700
Subject: [llvm-commits] [llvm] r54656 - in /llvm/trunk/lib:
ExecutionEngine/JIT/JITEmitter.cpp
Target/X86/X86CodeEmitter.cpp Target/X86/X86ISelDAGToDAG.cpp
Target/X86/X86TargetMachine.cpp
In-Reply-To: <200808112346.m7BNkQ28022561@zion.cs.uiuc.edu>
References: <200808112346.m7BNkQ28022561@zion.cs.uiuc.edu>
Message-ID:
Hi Dale,
This is causing a bunch of regressions on x86-64 JIT,
for example MultiSource/Applications/Burg. Can you investigate?
Thanks,
Dan
On Aug 11, 2008, at 4:46 PM, Dale Johannesen wrote:
> Author: johannes
> Date: Mon Aug 11 18:46:25 2008
> New Revision: 54656
>
> URL: http://llvm.org/viewvc/llvm-project?rev=54656&view=rev
> Log:
> Some fixes for x86-64 JIT. Make it use small code
> model, except for external calls; this makes
> addressing modes PC-relative. Incomplete.
>
> The assertion at the top of Emitter::runOnMachineFunction
> was obviously bogus (always true) so I removed it.
> If someone knows what the correct test should be to cover
> all the various targets, please fix.
>
>
> Modified:
> llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
> llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
> llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
> llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
>
> Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=54656&r1=54655&r2=54656&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon Aug 11
> 18:46:25 2008
> @@ -920,9 +920,22 @@
> Relocations.clear();
>
> #ifndef NDEBUG
> + {
> + DOUT << std::hex;
> + int i;
> + unsigned char* q = FnStart;
> + for (i=1; q!=FnEnd; q++, i++) {
> + if (i%8==1)
> + DOUT << "0x" << (long)q << ": ";
> + DOUT<< (unsigned short)*q << " ";
> + if (i%8==0)
> + DOUT<<"\n";
> + }
> + DOUT << std::dec;
> if (sys::hasDisassembler())
> DOUT << "Disassembled code:\n"
> << sys::disassembleBuffer(FnStart, FnEnd-FnStart,
> (uintptr_t)FnStart);
> + }
> #endif
> if (ExceptionHandling) {
> uintptr_t ActualSize = 0;
>
> Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=54656&r1=54655&r2=54656&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Mon Aug 11 18:46:25
> 2008
> @@ -106,10 +106,7 @@
> }
>
> bool Emitter::runOnMachineFunction(MachineFunction &MF) {
> - assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
> - MF.getTarget().getRelocationModel() != Reloc::Static) &&
> - "JIT relocation model must be set to static or default!");
> -
> +
> MCE.setModuleInfo(&getAnalysis());
>
> II = TM.getInstrInfo();
> @@ -517,11 +514,16 @@
>
> if (CurOp != NumOps) {
> const MachineOperand &MO = MI.getOperand(CurOp++);
> +DOUT << "RawFrm CurOp " << CurOp << "\n";
> +DOUT << "isMachineBasicBlock " << MO.isMachineBasicBlock() << "\n";
> +DOUT << "isGlobalAddress " << MO.isGlobalAddress() << "\n";
> +DOUT << "isExternalSymbol " << MO.isExternalSymbol() << "\n";
> +DOUT << "isImmediate " << MO.isImmediate() << "\n";
> if (MO.isMachineBasicBlock()) {
> emitPCRelativeBlockAddress(MO.getMBB());
> } else if (MO.isGlobalAddress()) {
> - bool NeedStub = (Is64BitMode && TM.getCodeModel() ==
> CodeModel::Large)
> - || Opcode == X86::TAILJMPd;
> + // Assume undefined functions may be outside the Small
> codespace.
> + bool NeedStub = Is64BitMode || Opcode == X86::TAILJMPd;
> emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word,
> 0, 0, NeedStub);
> } else if (MO.isExternalSymbol()) {
> @@ -545,8 +547,6 @@
> else {
> unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
> : (IsPIC ? X86::reloc_picrel_word :
> X86::reloc_absolute_word);
> - if (Opcode == X86::MOV64ri)
> - rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
> if (MO1.isGlobalAddress()) {
> bool NeedStub = isa(MO1.getGlobal());
> bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
> @@ -617,8 +617,6 @@
> else {
> unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
> : (IsPIC ? X86::reloc_picrel_word :
> X86::reloc_absolute_word);
> - if (Opcode == X86::MOV64ri32)
> - rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
> if (MO1.isGlobalAddress()) {
> bool NeedStub = isa(MO1.getGlobal());
> bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
> @@ -654,8 +652,6 @@
> else {
> unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
> : (IsPIC ? X86::reloc_picrel_word :
> X86::reloc_absolute_word);
> - if (Opcode == X86::MOV64mi32)
> - rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
> if (MO.isGlobalAddress()) {
> bool NeedStub = isa(MO.getGlobal());
> bool isLazy = gvNeedsLazyPtr(MO.getGlobal());
>
> Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=54656&r1=54655&r2=54656&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Aug 11
> 18:46:25 2008
> @@ -35,6 +35,7 @@
> #include "llvm/Support/Compiler.h"
> #include "llvm/Support/Debug.h"
> #include "llvm/Support/MathExtras.h"
> +#include "llvm/Support/Streams.h"
> #include "llvm/ADT/SmallPtrSet.h"
> #include "llvm/ADT/Statistic.h"
> #include
> @@ -77,6 +78,23 @@
> : BaseType(RegBase), isRIPRel(false), Scale(1), IndexReg(),
> Disp(0),
> GV(0), CP(0), ES(0), JT(-1), Align(0) {
> }
> + void dump() {
> + cerr << "X86ISelAddressMode " << this << "\n";
> + cerr << "Base.Reg "; if (Base.Reg.Val!=0) Base.Reg.Val->dump();
> + else cerr << "nul";
> + cerr << " Base.FrameIndex " << Base.FrameIndex << "\n";
> + cerr << "isRIPRel " << isRIPRel << " Scale" << Scale << "\n";
> + cerr << "IndexReg "; if (IndexReg.Val!=0) IndexReg.Val->dump();
> + else cerr << "nul";
> + cerr << " Disp " << Disp << "\n";
> + cerr << "GV "; if (GV) GV->dump();
> + else cerr << "nul";
> + cerr << " CP "; if (CP) CP->dump();
> + else cerr << "nul";
> + cerr << "\n";
> + cerr << "ES "; if (ES) cerr << ES; else cerr << "nul";
> + cerr << " JT" << JT << " Align" << Align << "\n";
> + }
> };
> }
>
> @@ -676,6 +694,7 @@
> /// addressing mode.
> bool X86DAGToDAGISel::MatchAddress(SDValue N, X86ISelAddressMode &AM,
> bool isRoot, unsigned Depth) {
> +DOUT << "MatchAddress: "; DEBUG(AM.dump());
> // Limit recursion.
> if (Depth > 5)
> return MatchAddressBase(N, AM, isRoot, Depth);
> @@ -707,6 +726,9 @@
> }
>
> case X86ISD::Wrapper: {
> +DOUT << "Wrapper: 64bit " << Subtarget->is64Bit();
> +DOUT << " AM "; DEBUG(AM.dump()); DOUT << "\n";
> +DOUT << "AlreadySelected " << AlreadySelected << "\n";
> bool is64Bit = Subtarget->is64Bit();
> // Under X86-64 non-small code model, GV (and friends) are 64-
> bits.
> // Also, base and index reg must be 0 in order to use rip as base.
>
> Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=54656&r1=54655&r2=54656&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Aug 11
> 18:46:25 2008
> @@ -194,12 +194,14 @@
> bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
> bool DumpAsm,
> MachineCodeEmitter &MCE) {
> // FIXME: Move this to TargetJITInfo!
> - if (DefRelocModel == Reloc::Default)
> + // Do not override 64-bit setting made in X86TargetMachine().
> + if (DefRelocModel == Reloc::Default && !Subtarget.is64Bit())
> setRelocationModel(Reloc::Static);
>
> - // JIT cannot ensure globals are placed in the lower 4G of address.
> + // 64-bit JIT places everything in the same buffer except
> external functions.
> + // Use small code model but hack the call instruction for
> externals.
> if (Subtarget.is64Bit())
> - setCodeModel(CodeModel::Large);
> + setCodeModel(CodeModel::Small);
>
> PM.add(createX86CodeEmitterPass(*this, MCE));
> if (DumpAsm)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
From dalej at apple.com Tue Aug 12 12:04:13 2008
From: dalej at apple.com (Dale Johannesen)
Date: Tue, 12 Aug 2008 10:04:13 -0700
Subject: [llvm-commits] [llvm] r54656 - in /llvm/trunk/lib:
ExecutionEngine/JIT/JITEmitter.cpp Target/X86/X86CodeEmitter.cpp
Target/X86/X86ISelDAGToDAG.cpp Target/X86/X86TargetMachine.cpp
In-Reply-To:
References: <200808112346.m7BNkQ28022561@zion.cs.uiuc.edu>
Message-ID: <5BE9E5ED-503F-49A0-980A-5226C1AD1967@apple.com>
Yeah, I know. Investigating. We can back it out if there's demand,
but it only affects x86-64 JIT.
On Aug 12, 2008, at 10:01 AMPDT, Dan Gohman wrote:
> Hi Dale,
>
> This is causing a bunch of regressions on x86-64 JIT,
> for example MultiSource/Applications/Burg. Can you investigate?
>
> Thanks,
>
> Dan
>
> On Aug 11, 2008, at 4:46 PM, Dale Johannesen wrote:
>
>> Author: johannes
>> Date: Mon Aug 11 18:46:25 2008
>> New Revision: 54656
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=54656&view=rev
>> Log:
>> Some fixes for x86-64 JIT. Make it use small code
>> model, except for external calls; this makes
>> addressing modes PC-relative. Incomplete.
>>
>> The assertion at the top of Emitter::runOnMachineFunction
>> was obviously bogus (always true) so I removed it.
>> If someone knows what the correct test should be to cover
>> all the various targets, please fix.
>>
>>
>> Modified:
>> llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
>> llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
>> llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
>> llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
>>
>> Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=54656&r1=54655&r2=54656&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
>> +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon Aug 11
>> 18:46:25 2008
>> @@ -920,9 +920,22 @@
>> Relocations.clear();
>>
>> #ifndef NDEBUG
>> + {
>> + DOUT << std::hex;
>> + int i;
>> + unsigned char* q = FnStart;
>> + for (i=1; q!=FnEnd; q++, i++) {
>> + if (i%8==1)
>> + DOUT << "0x" << (long)q << ": ";
>> + DOUT<< (unsigned short)*q << " ";
>> + if (i%8==0)
>> + DOUT<<"\n";
>> + }
>> + DOUT << std::dec;
>> if (sys::hasDisassembler())
>> DOUT << "Disassembled code:\n"
>> << sys::disassembleBuffer(FnStart, FnEnd-FnStart,
>> (uintptr_t)FnStart);
>> + }
>> #endif
>> if (ExceptionHandling) {
>> uintptr_t ActualSize = 0;
>>
>> Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=54656&r1=54655&r2=54656&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Mon Aug 11 18:46:25
>> 2008
>> @@ -106,10 +106,7 @@
>> }
>>
>> bool Emitter::runOnMachineFunction(MachineFunction &MF) {
>> - assert((MF.getTarget().getRelocationModel() != Reloc::Default ||
>> - MF.getTarget().getRelocationModel() != Reloc::Static) &&
>> - "JIT relocation model must be set to static or default!");
>> -
>> +
>> MCE.setModuleInfo(&getAnalysis());
>>
>> II = TM.getInstrInfo();
>> @@ -517,11 +514,16 @@
>>
>> if (CurOp != NumOps) {
>> const MachineOperand &MO = MI.getOperand(CurOp++);
>> +DOUT << "RawFrm CurOp " << CurOp << "\n";
>> +DOUT << "isMachineBasicBlock " << MO.isMachineBasicBlock() << "\n";
>> +DOUT << "isGlobalAddress " << MO.isGlobalAddress() << "\n";
>> +DOUT << "isExternalSymbol " << MO.isExternalSymbol() << "\n";
>> +DOUT << "isImmediate " << MO.isImmediate() << "\n";
>> if (MO.isMachineBasicBlock()) {
>> emitPCRelativeBlockAddress(MO.getMBB());
>> } else if (MO.isGlobalAddress()) {
>> - bool NeedStub = (Is64BitMode && TM.getCodeModel() ==
>> CodeModel::Large)
>> - || Opcode == X86::TAILJMPd;
>> + // Assume undefined functions may be outside the Small
>> codespace.
>> + bool NeedStub = Is64BitMode || Opcode == X86::TAILJMPd;
>> emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word,
>> 0, 0, NeedStub);
>> } else if (MO.isExternalSymbol()) {
>> @@ -545,8 +547,6 @@
>> else {
>> unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
>> : (IsPIC ? X86::reloc_picrel_word :
>> X86::reloc_absolute_word);
>> - if (Opcode == X86::MOV64ri)
>> - rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
>> if (MO1.isGlobalAddress()) {
>> bool NeedStub = isa(MO1.getGlobal());
>> bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
>> @@ -617,8 +617,6 @@
>> else {
>> unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
>> : (IsPIC ? X86::reloc_picrel_word :
>> X86::reloc_absolute_word);
>> - if (Opcode == X86::MOV64ri32)
>> - rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
>> if (MO1.isGlobalAddress()) {
>> bool NeedStub = isa(MO1.getGlobal());
>> bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
>> @@ -654,8 +652,6 @@
>> else {
>> unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
>> : (IsPIC ? X86::reloc_picrel_word :
>> X86::reloc_absolute_word);
>> - if (Opcode == X86::MOV64mi32)
>> - rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
>> if (MO.isGlobalAddress()) {
>> bool NeedStub = isa(MO.getGlobal());
>> bool isLazy = gvNeedsLazyPtr(MO.getGlobal());
>>
>> Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=54656&r1=54655&r2=54656&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Aug 11
>> 18:46:25 2008
>> @@ -35,6 +35,7 @@
>> #include "llvm/Support/Compiler.h"
>> #include "llvm/Support/Debug.h"
>> #include "llvm/Support/MathExtras.h"
>> +#include "llvm/Support/Streams.h"
>> #include "llvm/ADT/SmallPtrSet.h"
>> #include "llvm/ADT/Statistic.h"
>> #include
>> @@ -77,6 +78,23 @@
>> : BaseType(RegBase), isRIPRel(false), Scale(1), IndexReg(),
>> Disp(0),
>> GV(0), CP(0), ES(0), JT(-1), Align(0) {
>> }
>> + void dump() {
>> + cerr << "X86ISelAddressMode " << this << "\n";
>> + cerr << "Base.Reg "; if (Base.Reg.Val!=0) Base.Reg.Val-
>> >dump();
>> + else cerr << "nul";
>> + cerr << " Base.FrameIndex " << Base.FrameIndex << "\n";
>> + cerr << "isRIPRel " << isRIPRel << " Scale" << Scale << "\n";
>> + cerr << "IndexReg "; if (IndexReg.Val!=0) IndexReg.Val-
>> >dump();
>> + else cerr << "nul";
>> + cerr << " Disp " << Disp << "\n";
>> + cerr << "GV "; if (GV) GV->dump();
>> + else cerr << "nul";
>> + cerr << " CP "; if (CP) CP->dump();
>> + else cerr << "nul";
>> + cerr << "\n";
>> + cerr << "ES "; if (ES) cerr << ES; else cerr << "nul";
>> + cerr << " JT" << JT << " Align" << Align << "\n";
>> + }
>> };
>> }
>>
>> @@ -676,6 +694,7 @@
>> /// addressing mode.
>> bool X86DAGToDAGISel::MatchAddress(SDValue N, X86ISelAddressMode &AM,
>> bool isRoot, unsigned Depth) {
>> +DOUT << "MatchAddress: "; DEBUG(AM.dump());
>> // Limit recursion.
>> if (Depth > 5)
>> return MatchAddressBase(N, AM, isRoot, Depth);
>> @@ -707,6 +726,9 @@
>> }
>>
>> case X86ISD::Wrapper: {
>> +DOUT << "Wrapper: 64bit " << Subtarget->is64Bit();
>> +DOUT << " AM "; DEBUG(AM.dump()); DOUT << "\n";
>> +DOUT << "AlreadySelected " << AlreadySelected << "\n";
>> bool is64Bit = Subtarget->is64Bit();
>> // Under X86-64 non-small code model, GV (and friends) are 64-
>> bits.
>> // Also, base and index reg must be 0 in order to use rip as base.
>>
>> Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=54656&r1=54655&r2=54656&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Aug 11
>> 18:46:25 2008
>> @@ -194,12 +194,14 @@
>> bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
>> bool DumpAsm,
>> MachineCodeEmitter &MCE) {
>> // FIXME: Move this to TargetJITInfo!
>> - if (DefRelocModel == Reloc::Default)
>> + // Do not override 64-bit setting made in X86TargetMachine().
>> + if (DefRelocModel == Reloc::Default && !Subtarget.is64Bit())
>> setRelocationModel(Reloc::Static);
>>
>> - // JIT cannot ensure globals are placed in the lower 4G of
>> address.
>> + // 64-bit JIT places everything in the same buffer except
>> external functions.
>> + // Use small code model but hack the call instruction for
>> externals.
>> if (Subtarget.is64Bit())
>> - setCodeModel(CodeModel::Large);
>> + setCodeModel(CodeModel::Small);
>>
>> PM.add(createX86CodeEmitterPass(*this, MCE));
>> if (DumpAsm)
>>
>>
>> _______________________________________________
>> 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 gohman at apple.com Tue Aug 12 12:41:12 2008
From: gohman at apple.com (Dan Gohman)
Date: Tue, 12 Aug 2008 17:41:12 -0000
Subject: [llvm-commits] [llvm] r54687 -
/llvm/trunk/lib/Support/FoldingSet.cpp
Message-ID: <200808121741.m7CHfixi005478@zion.cs.uiuc.edu>
Author: djg
Date: Tue Aug 12 12:40:22 2008
New Revision: 54687
URL: http://llvm.org/viewvc/llvm-project?rev=54687&view=rev
Log:
Avoid repeatedly reallocating the FoldingSetNodeID when searching
through multiple nodes in a bucket.
Modified:
llvm/trunk/lib/Support/FoldingSet.cpp
Modified: llvm/trunk/lib/Support/FoldingSet.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FoldingSet.cpp?rev=54687&r1=54686&r2=54687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FoldingSet.cpp (original)
+++ llvm/trunk/lib/Support/FoldingSet.cpp Tue Aug 12 12:40:22 2008
@@ -232,6 +232,7 @@
Buckets[NumBuckets] = reinterpret_cast(-1);
// Walk the old buckets, rehashing nodes into their new place.
+ FoldingSetNodeID ID;
for (unsigned i = 0; i != OldNumBuckets; ++i) {
void *Probe = OldBuckets[i];
if (!Probe) continue;
@@ -241,9 +242,9 @@
NodeInBucket->SetNextInBucket(0);
// Insert the node into the new bucket, after recomputing the hash.
- FoldingSetNodeID ID;
GetNodeProfile(ID, NodeInBucket);
InsertNode(NodeInBucket, GetBucketFor(ID, Buckets, NumBuckets));
+ ID.clear();
}
}
@@ -262,13 +263,14 @@
InsertPos = 0;
+ FoldingSetNodeID OtherID;
while (Node *NodeInBucket = GetNextPtr(Probe)) {
- FoldingSetNodeID OtherID;
GetNodeProfile(OtherID, NodeInBucket);
if (OtherID == ID)
return NodeInBucket;
Probe = NodeInBucket->getNextInBucket();
+ OtherID.clear();
}
// Didn't find the node, return null with the bucket as the InsertPos.
From gohman at apple.com Tue Aug 12 12:43:18 2008
From: gohman at apple.com (Dan Gohman)
Date: Tue, 12 Aug 2008 17:43:18 -0000
Subject: [llvm-commits] [llvm] r54688 -
/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
Message-ID: <200808121743.m7CHhMC4005543@zion.cs.uiuc.edu>
Author: djg
Date: Tue Aug 12 12:42:33 2008
New Revision: 54688
URL: http://llvm.org/viewvc/llvm-project?rev=54688&view=rev
Log:
Correct the filename in the top-of-file comment.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=54688&r1=54687&r2=54688&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Tue Aug 12 12:42:33 2008
@@ -1,4 +1,4 @@
-//===----- ScheduleDAGList.cpp - Reg pressure reduction list scheduler ----===//
+//===----- ScheduleDAGRRList.cpp - Reg pressure reduction list scheduler --===//
//
// The LLVM Compiler Infrastructure
//
From dalej at apple.com Tue Aug 12 13:23:56 2008
From: dalej at apple.com (Dale Johannesen)
Date: Tue, 12 Aug 2008 18:23:56 -0000
Subject: [llvm-commits] [llvm] r54692 -
/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
Message-ID: <200808121823.m7CINul8007085@zion.cs.uiuc.edu>
Author: johannes
Date: Tue Aug 12 13:23:48 2008
New Revision: 54692
URL: http://llvm.org/viewvc/llvm-project?rev=54692&view=rev
Log:
In the absence of a linker to build the GOT, use the 32-bit
non_lazy_ptr mechanism on x86-64 Darwin JIT. Fixes a bunch
of last night's failures.
Modified:
llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=54692&r1=54691&r2=54692&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Tue Aug 12 13:23:48 2008
@@ -251,7 +251,9 @@
}
bool Emitter::gvNeedsLazyPtr(const GlobalValue *GV) {
- return !Is64BitMode &&
+ // For Darwin, simulate the linktime GOT by using the same lazy-pointer
+ // mechanism as 32-bit mode.
+ return (!Is64BitMode || TM.getSubtarget().isTargetDarwin()) &&
TM.getSubtarget().GVRequiresExtraLoad(GV, TM, false);
}
From grosbach at apple.com Tue Aug 12 13:34:48 2008
From: grosbach at apple.com (Jim Grosbach)
Date: Tue, 12 Aug 2008 18:34:48 -0000
Subject: [llvm-commits] [llvm] r54695 -
/llvm/trunk/lib/Target/ARM/README-Thumb.txt
Message-ID: <200808121834.m7CIYnhJ007617@zion.cs.uiuc.edu>
Author: grosbach
Date: Tue Aug 12 13:34:45 2008
New Revision: 54695
URL: http://llvm.org/viewvc/llvm-project?rev=54695&view=rev
Log:
Whitespace cleanup. Test commit.
Modified:
llvm/trunk/lib/Target/ARM/README-Thumb.txt
Modified: llvm/trunk/lib/Target/ARM/README-Thumb.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README-Thumb.txt?rev=54695&r1=54694&r2=54695&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/README-Thumb.txt (original)
+++ llvm/trunk/lib/Target/ARM/README-Thumb.txt Tue Aug 12 13:34:45 2008
@@ -4,6 +4,7 @@
* Add support for compiling functions in both ARM and Thumb mode, then taking
the smallest.
+
* Add support for compiling individual basic blocks in thumb mode, when in a
larger ARM function. This can be used for presumed cold code, like paths
to abort (failure path of asserts), EH handling code, etc.
From baldrick at free.fr Tue Aug 12 13:49:16 2008
From: baldrick at free.fr (Duncan Sands)
Date: Tue, 12 Aug 2008 20:49:16 +0200
Subject: [llvm-commits] [llvm] r54692 -
/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
In-Reply-To: <200808121823.m7CINul8007085@zion.cs.uiuc.edu>
References: <200808121823.m7CINul8007085@zion.cs.uiuc.edu>
Message-ID: <200808122049.17219.baldrick@free.fr>
> In the absence of a linker to build the GOT, use the 32-bit
> non_lazy_ptr mechanism on x86-64 Darwin JIT. Fixes a bunch
> of last night's failures.
There were a bunch of JIT failures on x86-64 linux too...
Ciao,
Duncan.
From dalej at apple.com Tue Aug 12 15:13:55 2008
From: dalej at apple.com (Dale Johannesen)
Date: Tue, 12 Aug 2008 13:13:55 -0700
Subject: [llvm-commits] [llvm] r54692 -
/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
In-Reply-To: <200808122049.17219.baldrick@free.fr>
References: <200808121823.m7CINul8007085@zion.cs.uiuc.edu>
<200808122049.17219.baldrick@free.fr>
Message-ID: <16732F84-97B1-46F8-A552-81EAB11DE942@apple.com>
On Aug 12, 2008, at 11:49 AMPDT, Duncan Sands wrote:
>> In the absence of a linker to build the GOT, use the 32-bit
>> non_lazy_ptr mechanism on x86-64 Darwin JIT. Fixes a bunch
>> of last night's failures.
>
> There were a bunch of JIT failures on x86-64 linux too...
So there are, and not all the same ones. I guess I'll put x86-64
Linux behavior back the way it was. On Darwin we need JIT codegen
to be PC-relative, which it wasn't, but AFAIK there is no such need
on Linux...
From gohman at apple.com Tue Aug 12 15:17:33 2008
From: gohman at apple.com (Dan Gohman)
Date: Tue, 12 Aug 2008 20:17:33 -0000
Subject: [llvm-commits] [llvm] r54697 - in /llvm/trunk:
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/avoid-smax.ll
Message-ID: <200808122017.m7CKHYEw011514@zion.cs.uiuc.edu>
Author: djg
Date: Tue Aug 12 15:17:31 2008
New Revision: 54697
URL: http://llvm.org/viewvc/llvm-project?rev=54697&view=rev
Log:
Extend ScalarEvolution's executesAtLeastOnce logic to be able to
continue past the first conditional branch when looking for a
relevant test. This helps it avoid using MAX expressions in
loop trip counts in more cases.
Added:
llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax.ll
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=54697&r1=54696&r2=54697&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Aug 12 15:17:31 2008
@@ -2709,66 +2709,68 @@
SCEV *LHS, SCEV *RHS) {
BasicBlock *Preheader = L->getLoopPreheader();
BasicBlock *PreheaderDest = L->getHeader();
- if (Preheader == 0) return false;
- BranchInst *LoopEntryPredicate =
- dyn_cast(Preheader->getTerminator());
- if (!LoopEntryPredicate) return false;
-
- // This might be a critical edge broken out. If the loop preheader ends in
- // an unconditional branch to the loop, check to see if the preheader has a
- // single predecessor, and if so, look for its terminator.
- while (LoopEntryPredicate->isUnconditional()) {
- PreheaderDest = Preheader;
- Preheader = Preheader->getSinglePredecessor();
- if (!Preheader) return false; // Multiple preds.
-
- LoopEntryPredicate =
+ // Starting at the preheader, climb up the predecessor chain, as long as
+ // there are unique predecessors, looking for a conditional branch that
+ // protects the loop.
+ //
+ // This is a conservative apporoximation of a climb of the
+ // control-dependence predecessors.
+
+ for (; Preheader; PreheaderDest = Preheader,
+ Preheader = Preheader->getSinglePredecessor()) {
+
+ BranchInst *LoopEntryPredicate =
dyn_cast(Preheader->getTerminator());
- if (!LoopEntryPredicate) return false;
- }
+ if (!LoopEntryPredicate ||
+ LoopEntryPredicate->isUnconditional())
+ continue;
+
+ ICmpInst *ICI = dyn_cast(LoopEntryPredicate->getCondition());
+ if (!ICI) continue;
+
+ // Now that we found a conditional branch that dominates the loop, check to
+ // see if it is the comparison we are looking for.
+ Value *PreCondLHS = ICI->getOperand(0);
+ Value *PreCondRHS = ICI->getOperand(1);
+ ICmpInst::Predicate Cond;
+ if (LoopEntryPredicate->getSuccessor(0) == PreheaderDest)
+ Cond = ICI->getPredicate();
+ else
+ Cond = ICI->getInversePredicate();
+
+ switch (Cond) {
+ case ICmpInst::ICMP_UGT:
+ if (isSigned) continue;
+ std::swap(PreCondLHS, PreCondRHS);
+ Cond = ICmpInst::ICMP_ULT;
+ break;
+ case ICmpInst::ICMP_SGT:
+ if (!isSigned) continue;
+ std::swap(PreCondLHS, PreCondRHS);
+ Cond = ICmpInst::ICMP_SLT;
+ break;
+ case ICmpInst::ICMP_ULT:
+ if (isSigned) continue;
+ break;
+ case ICmpInst::ICMP_SLT:
+ if (!isSigned) continue;
+ break;
+ default:
+ continue;
+ }
- ICmpInst *ICI = dyn_cast(LoopEntryPredicate->getCondition());
- if (!ICI) return false;
+ if (!PreCondLHS->getType()->isInteger()) continue;
- // Now that we found a conditional branch that dominates the loop, check to
- // see if it is the comparison we are looking for.
- Value *PreCondLHS = ICI->getOperand(0);
- Value *PreCondRHS = ICI->getOperand(1);
- ICmpInst::Predicate Cond;
- if (LoopEntryPredicate->getSuccessor(0) == PreheaderDest)
- Cond = ICI->getPredicate();
- else
- Cond = ICI->getInversePredicate();
-
- switch (Cond) {
- case ICmpInst::ICMP_UGT:
- if (isSigned) return false;
- std::swap(PreCondLHS, PreCondRHS);
- Cond = ICmpInst::ICMP_ULT;
- break;
- case ICmpInst::ICMP_SGT:
- if (!isSigned) return false;
- std::swap(PreCondLHS, PreCondRHS);
- Cond = ICmpInst::ICMP_SLT;
- break;
- case ICmpInst::ICMP_ULT:
- if (isSigned) return false;
- break;
- case ICmpInst::ICMP_SLT:
- if (!isSigned) return false;
- break;
- default:
- return false;
+ SCEVHandle PreCondLHSSCEV = getSCEV(PreCondLHS);
+ SCEVHandle PreCondRHSSCEV = getSCEV(PreCondRHS);
+ if ((LHS == PreCondLHSSCEV && RHS == PreCondRHSSCEV) ||
+ (LHS == SE.getNotSCEV(PreCondRHSSCEV) &&
+ RHS == SE.getNotSCEV(PreCondLHSSCEV)))
+ return true;
}
- if (!PreCondLHS->getType()->isInteger()) return false;
-
- SCEVHandle PreCondLHSSCEV = getSCEV(PreCondLHS);
- SCEVHandle PreCondRHSSCEV = getSCEV(PreCondRHS);
- return (LHS == PreCondLHSSCEV && RHS == PreCondRHSSCEV) ||
- (LHS == SE.getNotSCEV(PreCondRHSSCEV) &&
- RHS == SE.getNotSCEV(PreCondLHSSCEV));
+ return false;
}
/// HowManyLessThans - Return the number of times a backedge containing the
Added: llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax.ll?rev=54697&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax.ll (added)
+++ llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax.ll Tue Aug 12 15:17:31 2008
@@ -0,0 +1,35 @@
+; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop bb3: ( -1 + %n) iterations!}
+
+; We don't want to use a max in the trip count expression in
+; this testcase.
+
+define void @foo(i32 %n, i32* %p, i32* %q) nounwind {
+entry:
+ icmp sgt i32 %n, 0
+ br i1 %0, label %bb, label %return
+
+bb:
+ load i32* %q, align 4
+ icmp eq i32 %1, 0
+ br i1 %2, label %return, label %bb3.preheader
+
+bb3.preheader:
+ br label %bb3
+
+bb3:
+ %i.0 = phi i32 [ %7, %bb3 ], [ 0, %bb3.preheader ]
+ getelementptr i32* %p, i32 %i.0
+ load i32* %3, align 4
+ add i32 %4, 1
+ getelementptr i32* %p, i32 %i.0
+ store i32 %5, i32* %6, align 4
+ add i32 %i.0, 1
+ icmp slt i32 %7, %n
+ br i1 %8, label %bb3, label %return.loopexit
+
+return.loopexit:
+ br label %return
+
+return:
+ ret void
+}
From baldrick at free.fr Tue Aug 12 15:39:37 2008
From: baldrick at free.fr (Duncan Sands)
Date: Tue, 12 Aug 2008 20:39:37 -0000
Subject: [llvm-commits] [llvm] r54698 - in /llvm/trunk/include/llvm/Support:
ConstantFolder.h IRBuilder.h NullFolder.h TargetFolder.h
Message-ID: <200808122039.m7CKdhQl012199@zion.cs.uiuc.edu>
Author: baldrick
Date: Tue Aug 12 15:39:27 2008
New Revision: 54698
URL: http://llvm.org/viewvc/llvm-project?rev=54698&view=rev
Log:
Add a NullFolder class that doesn't fold constants.
This may be used as the second IRBuilder template
parameter, the idea being that people learning LLVM
may find it helpful (several people asked on IRC
if it was possible to turn off constant folding
because it made it hard for them to see what was
going on). Compiles, but otherwise completely
untested.
Added:
llvm/trunk/include/llvm/Support/NullFolder.h
Modified:
llvm/trunk/include/llvm/Support/ConstantFolder.h
llvm/trunk/include/llvm/Support/IRBuilder.h
llvm/trunk/include/llvm/Support/TargetFolder.h
Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=54698&r1=54697&r2=54698&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ConstantFolder.h (original)
+++ llvm/trunk/include/llvm/Support/ConstantFolder.h Tue Aug 12 15:39:27 2008
@@ -134,8 +134,20 @@
// Compare Instructions
//===--------------------------------------------------------------------===//
- Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS,
- Constant *RHS) const {
+ Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
+ return ConstantExpr::getCompare(P, LHS, RHS);
+ }
+ Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
+ return ConstantExpr::getCompare(P, LHS, RHS);
+ }
+ Constant *CreateVICmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
+ return ConstantExpr::getCompare(P, LHS, RHS);
+ }
+ Constant *CreateVFCmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
return ConstantExpr::getCompare(P, LHS, RHS);
}
Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=54698&r1=54697&r2=54698&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Aug 12 15:39:27 2008
@@ -493,14 +493,14 @@
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return Folder.CreateCompare(P, LC, RC);
+ return Folder.CreateICmp(P, LC, RC);
return Insert(new ICmpInst(P, LHS, RHS), Name);
}
Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return Folder.CreateCompare(P, LC, RC);
+ return Folder.CreateFCmp(P, LC, RC);
return Insert(new FCmpInst(P, LHS, RHS), Name);
}
@@ -508,14 +508,14 @@
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return Folder.CreateCompare(P, LC, RC);
+ return Folder.CreateVICmp(P, LC, RC);
return Insert(new VICmpInst(P, LHS, RHS), Name);
}
Value *CreateVFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast(LHS))
if (Constant *RC = dyn_cast(RHS))
- return Folder.CreateCompare(P, LC, RC);
+ return Folder.CreateVFCmp(P, LC, RC);
return Insert(new VFCmpInst(P, LHS, RHS), Name);
}
Added: llvm/trunk/include/llvm/Support/NullFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/NullFolder.h?rev=54698&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/NullFolder.h (added)
+++ llvm/trunk/include/llvm/Support/NullFolder.h Tue Aug 12 15:39:27 2008
@@ -0,0 +1,178 @@
+//=====-- llvm/Support/NullFolder.h - Constant folding helper -*- C++ -*-=====//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the NullFolder class, a helper for IRBuilder. It provides
+// IRBuilder with a set of methods for creating unfolded constants. This is
+// useful for learners trying to understand how LLVM IR works, and who don't
+// want details to be hidden by the constant folder. For general constant
+// creation and folding, use ConstantExpr and the routines in
+// llvm/Analysis/ConstantFolding.h.
+//
+// Note: since it is not actually possible to create unfolded constants, this
+// class returns values rather than constants. The values do not have names,
+// even if names were provided to IRBuilder, which may be confusing.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_NULLFOLDER_H
+#define LLVM_SUPPORT_NULLFOLDER_H
+
+#include "llvm/Constants.h"
+#include "llvm/Instructions.h"
+
+namespace llvm {
+
+/// NullFolder - Create "constants" (actually, values) with no folding.
+class NullFolder {
+public:
+
+ //===--------------------------------------------------------------------===//
+ // Binary Operators
+ //===--------------------------------------------------------------------===//
+
+ Value *CreateAdd(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateAdd(LHS, RHS);
+ }
+ Value *CreateSub(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateSub(LHS, RHS);
+ }
+ Value *CreateMul(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateMul(LHS, RHS);
+ }
+ Value *CreateUDiv(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateUDiv(LHS, RHS);
+ }
+ Value *CreateSDiv(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateSDiv(LHS, RHS);
+ }
+ Value *CreateFDiv(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateFDiv(LHS, RHS);
+ }
+ Value *CreateURem(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateURem(LHS, RHS);
+ }
+ Value *CreateSRem(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateSRem(LHS, RHS);
+ }
+ Value *CreateFRem(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateFRem(LHS, RHS);
+ }
+ Value *CreateShl(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateShl(LHS, RHS);
+ }
+ Value *CreateLShr(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateLShr(LHS, RHS);
+ }
+ Value *CreateAShr(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateAShr(LHS, RHS);
+ }
+ Value *CreateAnd(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateAnd(LHS, RHS);
+ }
+ Value *CreateOr(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateOr(LHS, RHS);
+ }
+ Value *CreateXor(Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::CreateXor(LHS, RHS);
+ }
+
+ Value *CreateBinOp(Instruction::BinaryOps Opc,
+ Constant *LHS, Constant *RHS) const {
+ return BinaryOperator::Create(Opc, LHS, RHS);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Unary Operators
+ //===--------------------------------------------------------------------===//
+
+ Value *CreateNeg(Constant *C) const {
+ return BinaryOperator::CreateNeg(C);
+ }
+ Value *CreateNot(Constant *C) const {
+ return BinaryOperator::CreateNot(C);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Memory Instructions
+ //===--------------------------------------------------------------------===//
+
+ Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
+ unsigned NumIdx) const {
+ return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
+ }
+ Value *CreateGetElementPtr(Constant *C, Value* const *IdxList,
+ unsigned NumIdx) const {
+ return GetElementPtrInst::Create(C, IdxList, IdxList+NumIdx);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Cast/Conversion Operators
+ //===--------------------------------------------------------------------===//
+
+ Value *CreateCast(Instruction::CastOps Op, Constant *C,
+ const Type *DestTy) const {
+ return CastInst::Create(Op, C, DestTy);
+ }
+ Value *CreateIntCast(Constant *C, const Type *DestTy,
+ bool isSigned) const {
+ return CastInst::CreateIntegerCast(C, DestTy, isSigned);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Compare Instructions
+ //===--------------------------------------------------------------------===//
+
+ Value *CreateICmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const {
+ return new ICmpInst(P, LHS, RHS);
+ }
+ Value *CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const {
+ return new FCmpInst(P, LHS, RHS);
+ }
+ Value *CreateVICmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const {
+ return new VICmpInst(P, LHS, RHS);
+ }
+ Value *CreateVFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const {
+ return new VFCmpInst(P, LHS, RHS);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // Other Instructions
+ //===--------------------------------------------------------------------===//
+
+ Value *CreateSelect(Constant *C, Constant *True, Constant *False) const {
+ return SelectInst::Create(C, True, False);
+ }
+
+ Value *CreateExtractElement(Constant *Vec, Constant *Idx) const {
+ return new ExtractElementInst(Vec, Idx);
+ }
+
+ Value *CreateInsertElement(Constant *Vec, Constant *NewElt,
+ Constant *Idx) const {
+ return InsertElementInst::Create(Vec, NewElt, Idx);
+ }
+
+ Value *CreateShuffleVector(Constant *V1, Constant *V2, Constant *Mask) const {
+ return new ShuffleVectorInst(V1, V2, Mask);
+ }
+
+ Value *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
+ unsigned NumIdx) const {
+ return ExtractValueInst::Create(Agg, IdxList, IdxList+NumIdx);
+ }
+
+ Value *CreateInsertValue(Constant *Agg, Constant *Val,
+ const unsigned *IdxList, unsigned NumIdx) const {
+ return InsertValueInst::Create(Agg, Val, IdxList, IdxList+NumIdx);
+ }
+};
+
+}
+
+#endif
Modified: llvm/trunk/include/llvm/Support/TargetFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=54698&r1=54697&r2=54698&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TargetFolder.h (original)
+++ llvm/trunk/include/llvm/Support/TargetFolder.h Tue Aug 12 15:39:27 2008
@@ -154,8 +154,20 @@
// Compare Instructions
//===--------------------------------------------------------------------===//
- Constant *CreateCompare(CmpInst::Predicate P, Constant *LHS,
- Constant *RHS) const {
+ Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
+ return Fold(ConstantExpr::getCompare(P, LHS, RHS));
+ }
+ Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
+ return Fold(ConstantExpr::getCompare(P, LHS, RHS));
+ }
+ Constant *CreateVICmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
+ return Fold(ConstantExpr::getCompare(P, LHS, RHS));
+ }
+ Constant *CreateVFCmp(CmpInst::Predicate P, Constant *LHS,
+ Constant *RHS) const {
return Fold(ConstantExpr::getCompare(P, LHS, RHS));
}
From dalej at apple.com Tue Aug 12 16:02:09 2008
From: dalej at apple.com (Dale Johannesen)
Date: Tue, 12 Aug 2008 21:02:09 -0000
Subject: [llvm-commits] [llvm] r54700 - in /llvm/trunk/lib/Target/X86:
X86CodeEmitter.cpp X86TargetMachine.cpp
Message-ID: <200808122102.m7CL2Atv013106@zion.cs.uiuc.edu>
Author: johannes
Date: Tue Aug 12 16:02:08 2008
New Revision: 54700
URL: http://llvm.org/viewvc/llvm-project?rev=54700&view=rev
Log:
Make x86-64 JIT changes Darwin-specific.
Modified:
llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=54700&r1=54699&r2=54700&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Tue Aug 12 16:02:08 2008
@@ -525,7 +525,11 @@
emitPCRelativeBlockAddress(MO.getMBB());
} else if (MO.isGlobalAddress()) {
// Assume undefined functions may be outside the Small codespace.
- bool NeedStub = Is64BitMode || Opcode == X86::TAILJMPd;
+ bool NeedStub =
+ (Is64BitMode &&
+ (TM.getCodeModel() == CodeModel::Large ||
+ TM.getSubtarget().isTargetDarwin())) ||
+ Opcode == X86::TAILJMPd;
emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word,
0, 0, NeedStub);
} else if (MO.isExternalSymbol()) {
@@ -549,6 +553,9 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
+ // This should not occur on Darwin for relocatable objects.
+ if (Opcode == X86::MOV64ri)
+ rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
if (MO1.isGlobalAddress()) {
bool NeedStub = isa(MO1.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
@@ -619,6 +626,8 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
+ if (Opcode == X86::MOV64ri32)
+ rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO1.isGlobalAddress()) {
bool NeedStub = isa(MO1.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO1.getGlobal());
@@ -654,6 +663,8 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
+ if (Opcode == X86::MOV64mi32)
+ rt = X86::reloc_absolute_word; // FIXME: add X86II flag?
if (MO.isGlobalAddress()) {
bool NeedStub = isa(MO.getGlobal());
bool isLazy = gvNeedsLazyPtr(MO.getGlobal());
Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=54700&r1=54699&r2=54700&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Aug 12 16:02:08 2008
@@ -194,14 +194,20 @@
bool X86TargetMachine::addCodeEmitter(PassManagerBase &PM, bool Fast,
bool DumpAsm, MachineCodeEmitter &MCE) {
// FIXME: Move this to TargetJITInfo!
- // Do not override 64-bit setting made in X86TargetMachine().
- if (DefRelocModel == Reloc::Default && !Subtarget.is64Bit())
+ // On Darwin, do not override 64-bit setting made in X86TargetMachine().
+ if (DefRelocModel == Reloc::Default &&
+ (!Subtarget.isTargetDarwin() || !Subtarget.is64Bit()))
setRelocationModel(Reloc::Static);
// 64-bit JIT places everything in the same buffer except external functions.
- // Use small code model but hack the call instruction for externals.
- if (Subtarget.is64Bit())
- setCodeModel(CodeModel::Small);
+ // On Darwin, use small code model but hack the call instruction for
+ // externals. Elsewhere, do not assume globals are in the lower 4G.
+ if (Subtarget.is64Bit()) {
+ if (Subtarget.isTargetDarwin())
+ setCodeModel(CodeModel::Small);
+ else
+ setCodeModel(CodeModel::Large);
+ }
PM.add(createX86CodeEmitterPass(*this, MCE));
if (DumpAsm)
From sabre at nondot.org Tue Aug 12 16:11:01 2008
From: sabre at nondot.org (Chris Lattner)
Date: Tue, 12 Aug 2008 16:11:01 -0500
Subject: [llvm-commits] CVS: llvm-www/devmtg/2008-08/.htaccess
Message-ID: <200808122111.m7CLB1hj013570@zion.cs.uiuc.edu>
Changes in directory llvm-www/devmtg/2008-08:
.htaccess updated: 1.1 -> 1.2
---
Log message:
add another mime type
---
Diffs of the changes: (+1 -0)
.htaccess | 1 +
1 files changed, 1 insertion(+)
Index: llvm-www/devmtg/2008-08/.htaccess
diff -u llvm-www/devmtg/2008-08/.htaccess:1.1 llvm-www/devmtg/2008-08/.htaccess:1.2
--- llvm-www/devmtg/2008-08/.htaccess:1.1 Mon Aug 4 16:47:38 2008
+++ llvm-www/devmtg/2008-08/.htaccess Tue Aug 12 16:09:12 2008
@@ -2,3 +2,4 @@
AddType audio/x-m4a m4a
AddType video/x-m4v m4v
AddType video/mp4 mp4
+AddType video/3gpp 3gp
From grosbach at apple.com Tue Aug 12 16:13:56 2008
From: grosbach at apple.com (Jim Grosbach)
Date: Tue, 12 Aug 2008 21:13:56 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r54702 -
/llvm-gcc-4.2/trunk/gcc/Makefile.in
Message-ID: <200808122113.m7CLDujh013664@zion.cs.uiuc.edu>
Author: grosbach
Date: Tue Aug 12 16:13:55 2008
New Revision: 54702
URL: http://llvm.org/viewvc/llvm-project?rev=54702&view=rev
Log:
LLVM dylib needs the ARM backend as well.
Modified:
llvm-gcc-4.2/trunk/gcc/Makefile.in
Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=54702&r1=54701&r2=54702&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/Makefile.in (original)
+++ llvm-gcc-4.2/trunk/gcc/Makefile.in Tue Aug 12 16:13:55 2008
@@ -1152,10 +1152,10 @@
$(error Unsuported LLVM Target $(target))
endif
-# If in BUILD_LLVM_INTO_A_DYLIB mode, always link in the x86/ppc backends.
+# If in BUILD_LLVM_INTO_A_DYLIB mode, always link in the x86/ppc/arm backends.
# See below for more details.
ifdef BUILD_LLVM_INTO_A_DYLIB
-LLVMTARGETOBJ := $(sort $(LLVMTARGETOBJ) x86 powerpc)
+LLVMTARGETOBJ := $(sort $(LLVMTARGETOBJ) x86 powerpc arm)
endif
# We use llvm-config to determine the libraries that we need to link in our
From grosbach at apple.com Tue Aug 12 16:16:20 2008
From: grosbach at apple.com (Jim Grosbach)
Date: Tue, 12 Aug 2008 21:16:20 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r54703 - /llvm-gcc-4.2/trunk/build_gcc
Message-ID: <200808122116.m7CLGL6A013872@zion.cs.uiuc.edu>
Author: grosbach
Date: Tue Aug 12 16:16:20 2008
New Revision: 54703
URL: http://llvm.org/viewvc/llvm-project?rev=54703&view=rev
Log:
Apple-style build symlinks to usr/bin to be based on targets, not hosts.
Modified:
llvm-gcc-4.2/trunk/build_gcc
Modified: llvm-gcc-4.2/trunk/build_gcc
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/build_gcc?rev=54703&r1=54702&r2=54703&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/build_gcc (original)
+++ llvm-gcc-4.2/trunk/build_gcc Tue Aug 12 16:16:20 2008
@@ -575,9 +575,9 @@
ln -s -f ../llvm-gcc-$MAJ_VERS/bin/llvm-g++-$MAJ_VERS llvm-g++ || exit 1
# FIXME: This is a hack to get things working.
-for h in $HOSTS ; do
- ln -s -f ../llvm-gcc-$MAJ_VERS/bin/$h-apple-darwin$DARWIN_VERS-llvm-gcc-$MAJ_VERS $h-apple-darwin$DARWIN_VERS-llvm-gcc-$MAJ_VERS || exit 1
- ln -s -f ../llvm-gcc-$MAJ_VERS/bin/$h-apple-darwin$DARWIN_VERS-llvm-g++-$MAJ_VERS $h-apple-darwin$DARWIN_VERS-llvm-g++-$MAJ_VERS || exit 1
+for t in $TARGETS ; do
+ ln -s -f ../llvm-gcc-$MAJ_VERS/bin/$t-apple-darwin$DARWIN_VERS-llvm-gcc-$MAJ_VERS $t-apple-darwin$DARWIN_VERS-llvm-gcc-$MAJ_VERS || exit 1
+ ln -s -f ../llvm-gcc-$MAJ_VERS/bin/$t-apple-darwin$DARWIN_VERS-llvm-g++-$MAJ_VERS $t-apple-darwin$DARWIN_VERS-llvm-g++-$MAJ_VERS || exit 1
done
# Copy one of the libllvmgcc.dylib's up to libexec/gcc.
From isanbard at gmail.com Tue Aug 12 16:55:54 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Tue, 12 Aug 2008 21:55:54 -0000
Subject: [llvm-commits] [llvm] r54705 - /llvm/trunk/CREDITS.TXT
Message-ID: <200808122155.m7CLtsbS015128@zion.cs.uiuc.edu>
Author: void
Date: Tue Aug 12 16:55:54 2008
New Revision: 54705
URL: http://llvm.org/viewvc/llvm-project?rev=54705&view=rev
Log:
Update. Remove bogus webpage.
Modified:
llvm/trunk/CREDITS.TXT
Modified: llvm/trunk/CREDITS.TXT
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CREDITS.TXT?rev=54705&r1=54704&r2=54705&view=diff
==============================================================================
--- llvm/trunk/CREDITS.TXT (original)
+++ llvm/trunk/CREDITS.TXT Tue Aug 12 16:55:54 2008
@@ -266,7 +266,6 @@
N: Bill Wendling
E: isanbard at gmail.com
-W: http://web.mac.com/bwendling/
D: Darwin exception handling
D: MMX & SSSE3 instructions
D: SPEC2006 support
From isanbard at gmail.com Tue Aug 12 17:21:22 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Tue, 12 Aug 2008 22:21:22 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r54706 -
/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
Message-ID: <200808122221.m7CMLMZw015930@zion.cs.uiuc.edu>
Author: void
Date: Tue Aug 12 17:21:20 2008
New Revision: 54706
URL: http://llvm.org/viewvc/llvm-project?rev=54706&view=rev
Log:
Test commit: Remove tabs.
Modified:
llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=54706&r1=54705&r2=54706&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
+++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Aug 12 17:21:20 2008
@@ -82,7 +82,7 @@
#endif
/* LLVM LOCAL end */
-#define OBJC_VOID_AT_END void_list_node
+#define OBJC_VOID_AT_END void_list_node
/* APPLE LOCAL radar 4506893 */
static bool in_objc_property_setter_name_context = false;
@@ -104,15 +104,15 @@
if method names contain underscores. -- rms. */
#ifndef OBJC_GEN_METHOD_LABEL
#define OBJC_GEN_METHOD_LABEL(BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME, NUM) \
- do { \
- char *temp; \
- sprintf ((BUF), "_%s_%s_%s_%s", \
- ((IS_INST) ? "i" : "c"), \
- (CLASS_NAME), \
- ((CAT_NAME)? (CAT_NAME) : ""), \
- (SEL_NAME)); \
- for (temp = (BUF); *temp; temp++) \
- if (*temp == ':') *temp = '_'; \
+ do { \
+ char *temp; \
+ sprintf ((BUF), "_%s_%s_%s_%s", \
+ ((IS_INST) ? "i" : "c"), \
+ (CLASS_NAME), \
+ ((CAT_NAME)? (CAT_NAME) : ""), \
+ (SEL_NAME)); \
+ for (temp = (BUF); *temp; temp++) \
+ if (*temp == ':') *temp = '_'; \
} while (0)
#endif
/* APPLE LOCAL begin radar 4862848 */
@@ -175,8 +175,8 @@
#define NEW_PROTOCOL_VERSION 3
/* (Decide if these can ever be validly changed.) */
-#define OBJC_ENCODE_INLINE_DEFS 0
-#define OBJC_ENCODE_DONT_INLINE_DEFS 1
+#define OBJC_ENCODE_INLINE_DEFS 0
+#define OBJC_ENCODE_DONT_INLINE_DEFS 1
/*** Private Interface (procedures) ***/
@@ -14174,7 +14174,6 @@
/* APPLE LOCAL begin ObjC new abi */
/* APPLE LOCAL begin radar 5811191 - blocks */
decl = self_decl;
-#ifndef OBJCPLUS
if (cur_block)
{
/* Find a 'self' declaration in this block. If not found,
@@ -14182,16 +14181,17 @@
if (lookup_name_in_block (DECL_NAME (decl), &decl))
decl = lookup_name (DECL_NAME (decl));
else {
+#ifndef OBJCPLUS
if (building_block_byref_decl) {
warning (0, "ivar %qs may not be declared inside the 'byref' block - ignored",
IDENTIFIER_POINTER (id));
return error_mark_node;
}
+#endif
decl = build_block_ref_decl (DECL_NAME (decl), decl);
}
gcc_assert (decl);
}
-#endif
base = build_indirect_ref (decl, "->");
/* APPLE LOCAL end radar 5811191 - blocks */
if ((ivar = objc_v2_build_ivar_ref (base, id)))
From isanbard at gmail.com Tue Aug 12 18:15:46 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Tue, 12 Aug 2008 23:15:46 -0000
Subject: [llvm-commits] [llvm] r54707 -
/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Message-ID: <200808122315.m7CNFltQ017870@zion.cs.uiuc.edu>
Author: void
Date: Tue Aug 12 18:15:44 2008
New Revision: 54707
URL: http://llvm.org/viewvc/llvm-project?rev=54707&view=rev
Log:
Remove tabs.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=54707&r1=54706&r2=54707&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Aug 12 18:15:44 2008
@@ -988,7 +988,7 @@
// We permit two users of the load: setcc comparing against the null
// pointer, and a getelementptr of a specific form.
for (Value::use_iterator UI = LI->use_begin(), E = LI->use_end();
- UI != E; ++UI) {
+ UI != E; ++UI) {
// Comparison against null is ok.
if (ICmpInst *ICI = dyn_cast(*UI)) {
if (!isa(ICI->getOperand(1)))
@@ -1611,7 +1611,7 @@
// See if the function address is passed as an argument.
for (User::op_iterator i = User->op_begin() + 1, e = User->op_end();
- i != e; ++i)
+ i != e; ++i)
if (*i == F) return false;
}
return true;
From dalej at apple.com Tue Aug 12 18:20:24 2008
From: dalej at apple.com (Dale Johannesen)
Date: Tue, 12 Aug 2008 23:20:24 -0000
Subject: [llvm-commits] [llvm] r54708 -
/llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Message-ID: <200808122320.m7CNKOTw018027@zion.cs.uiuc.edu>
Author: johannes
Date: Tue Aug 12 18:20:24 2008
New Revision: 54708
URL: http://llvm.org/viewvc/llvm-project?rev=54708&view=rev
Log:
When resolving a stub in x86-64 JIT, use a PC-relative branch
rather than the absolute address if the target is within range.
Modified:
llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=54708&r1=54707&r2=54708&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Tue Aug 12 18:20:24 2008
@@ -352,7 +352,8 @@
// Rewrite the call target... so that we don't end up here every time we
// execute the call.
#if defined (X86_64_JIT)
- *(intptr_t *)(RetAddr - 0xa) = NewVal;
+ if (!isStub)
+ *(intptr_t *)(RetAddr - 0xa) = NewVal;
#else
*(intptr_t *)RetAddr = (intptr_t)(NewVal-RetAddr-4);
#endif
@@ -363,7 +364,18 @@
// when the requested function finally gets called. This also makes the
// 0xCD byte (interrupt) dead, so the marker doesn't effect anything.
#if defined (X86_64_JIT)
- ((unsigned char*)RetAddr)[0] = (2 | (4 << 3) | (3 << 6));
+ // If the target address is within 32-bit range of the stub, use a
+ // PC-relative branch instead of loading the actual address. (This is
+ // considerably shorter than the 64-bit immediate load already there.)
+ // We assume here intptr_t is 64 bits.
+ intptr_t diff = NewVal-RetAddr+7;
+ if (diff >= -2147483648LL && diff <= 2147483647LL) {
+ *(unsigned char*)(RetAddr-0xc) = 0xE9;
+ *(intptr_t *)(RetAddr-0xb) = diff & 0xffffffff;
+ } else {
+ *(intptr_t *)(RetAddr - 0xa) = NewVal;
+ ((unsigned char*)RetAddr)[0] = (2 | (4 << 3) | (3 << 6));
+ }
#else
((unsigned char*)RetAddr)[-1] = 0xE9;
#endif
From dpatel at apple.com Tue Aug 12 21:05:15 2008
From: dpatel at apple.com (Devang Patel)
Date: Wed, 13 Aug 2008 02:05:15 -0000
Subject: [llvm-commits] [llvm] r54710 - in /llvm/trunk:
lib/Transforms/Scalar/LoopStrengthReduce.cpp
test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll
Message-ID: <200808130205.m7D25GeJ023127@zion.cs.uiuc.edu>
Author: dpatel
Date: Tue Aug 12 21:05:14 2008
New Revision: 54710
URL: http://llvm.org/viewvc/llvm-project?rev=54710&view=rev
Log:
Check sign to detect overflow before changing compare stride.
Added:
llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=54710&r1=54709&r2=54710&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Aug 12 21:05:14 2008
@@ -1542,6 +1542,12 @@
Value *NewIncV = NULL;
int64_t Scale = 1;
+ // Check stride constant and the comparision constant signs to detect
+ // overflow.
+ if (ICmpInst::isSignedPredicate(Predicate) &&
+ (CmpVal & SignBit) != (CmpSSInt & SignBit))
+ return Cond;
+
// Look for a suitable stride / iv as replacement.
std::stable_sort(StrideOrder.begin(), StrideOrder.end(), StrideCompare());
for (unsigned i = 0, e = StrideOrder.size(); i != e; ++i) {
@@ -1640,11 +1646,12 @@
// before the branch. See
// test/Transforms/LoopStrengthReduce/change-compare-stride-trickiness-*.ll
// for an example of this situation.
- if (!Cond->hasOneUse())
+ if (!Cond->hasOneUse()) {
for (BasicBlock::iterator I = Cond, E = Cond->getParent()->end();
I != E; ++I)
if (I == NewIncV)
return Cond;
+ }
if (NewCmpVal != CmpVal) {
// Create a new compare instruction using new stride / iv.
Added: llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll?rev=54710&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll (added)
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/2008-08-13-CmpStride.ll Tue Aug 12 21:05:14 2008
@@ -0,0 +1,31 @@
+; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep add | count 2
+; PR 2662
+ at g_3 = common global i16 0 ; [#uses=2]
+@"\01LC" = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1]
+
+define void @func_1() nounwind {
+entry:
+ br label %bb
+
+bb: ; preds = %bb, %entry
+ %l_2.0.reg2mem.0 = phi i16 [ 0, %entry ], [ %t1, %bb ] ; [#uses=2]
+ %t0 = shl i16 %l_2.0.reg2mem.0, 1 ; :0 [#uses=1]
+ volatile store i16 %t0, i16* @g_3, align 2
+ %t1 = add i16 %l_2.0.reg2mem.0, -3 ; :1 [#uses=2]
+ %t2 = icmp slt i16 %t1, 1 ; :2 [#uses=1]
+ br i1 %t2, label %bb, label %return
+
+return: ; preds = %bb
+ ret void
+}
+
+define i32 @main() nounwind {
+entry:
+ tail call void @func_1( ) nounwind
+ volatile load i16* @g_3, align 2 ; :0 [#uses=1]
+ zext i16 %0 to i32 ; :1 [#uses=1]
+ tail call i32 (i8*, ...)* @printf( i8* getelementptr ([4 x i8]* @"\01LC", i32 0, i32 0), i32 %1 ) nounwind ; :2 [#uses=0]
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...) nounwind
From isanbard at gmail.com Tue Aug 12 21:49:36 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Wed, 13 Aug 2008 02:49:36 -0000
Subject: [llvm-commits] [llvm] r54711 -
/llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp
Message-ID: <200808130249.m7D2nabB024565@zion.cs.uiuc.edu>
Author: void
Date: Tue Aug 12 21:49:35 2008
New Revision: 54711
URL: http://llvm.org/viewvc/llvm-project?rev=54711&view=rev
Log:
Pull r54692 into llvmCore-2064:
In the absence of a linker to build the GOT, use the 32-bit
non_lazy_ptr mechanism on x86-64 Darwin JIT. Fixes a bunch
of last night's failures.
Modified:
llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp
Modified: llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp?rev=54711&r1=54710&r2=54711&view=diff
==============================================================================
--- llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp Tue Aug 12 21:49:35 2008
@@ -251,7 +251,9 @@
}
bool Emitter::gvNeedsLazyPtr(const GlobalValue *GV) {
- return !Is64BitMode &&
+ // For Darwin, simulate the linktime GOT by using the same lazy-pointer
+ // mechanism as 32-bit mode.
+ return (!Is64BitMode || TM.getSubtarget().isTargetDarwin()) &&
TM.getSubtarget().GVRequiresExtraLoad(GV, TM, false);
}
From isanbard at gmail.com Tue Aug 12 21:50:19 2008
From: isanbard at gmail.com (Bill Wendling)
Date: Wed, 13 Aug 2008 02:50:19 -0000
Subject: [llvm-commits] [llvm] r54712 - in
/llvm/tags/Apple/llvmCore-2064/lib/Target/X86: X86CodeEmitter.cpp
X86TargetMachine.cpp
Message-ID: <200808130250.m7D2oKLZ024599@zion.cs.uiuc.edu>
Author: void
Date: Tue Aug 12 21:50:19 2008
New Revision: 54712
URL: http://llvm.org/viewvc/llvm-project?rev=54712&view=rev
Log:
Pull r54700 into llvmCore-2064:
Make x86-64 JIT changes Darwin-specific.
Modified:
llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp
llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86TargetMachine.cpp
Modified: llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp?rev=54712&r1=54711&r2=54712&view=diff
==============================================================================
--- llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp (original)
+++ llvm/tags/Apple/llvmCore-2064/lib/Target/X86/X86CodeEmitter.cpp Tue Aug 12 21:50:19 2008
@@ -525,7 +525,11 @@
emitPCRelativeBlockAddress(MO.getMBB());
} else if (MO.isGlobalAddress()) {
// Assume undefined functions may be outside the Small codespace.
- bool NeedStub = Is64BitMode || Opcode == X86::TAILJMPd;
+ bool NeedStub =
+ (Is64BitMode &&
+ (TM.getCodeModel() == CodeModel::Large ||
+ TM.getSubtarget().isTargetDarwin())) ||
+ Opcode == X86::TAILJMPd;
emitGlobalAddress(MO.getGlobal(), X86::reloc_pcrel_word,
0, 0, NeedStub);
} else if (MO.isExternalSymbol()) {
@@ -549,6 +553,9 @@
else {
unsigned rt = Is64BitMode ? X86::reloc_pcrel_word
: (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word);
+ // This should not occur on Darwin for relocatable objects.
+ if (Opcode == X86::MOV64ri)
+ rt = X86::reloc_absolute_dword; // FIXME: add X86II flag?
if (MO1.isGlobalAddress()) {
bool NeedStub = isa