2007-12-08 20:24:38 +00:00
|
|
|
//===-- LegalizeTypes.cpp - Common code for DAG type legalizer ------------===//
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the SelectionDAG::LegalizeTypes method. It transforms
|
2007-12-08 20:24:38 +00:00
|
|
|
// an arbitrary well-formed SelectionDAG to only consist of legal types. This
|
|
|
|
// is common code shared among the LegalizeTypes*.cpp files.
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-12-08 20:16:06 +00:00
|
|
|
#include "LegalizeTypes.h"
|
2008-04-14 06:48:48 +00:00
|
|
|
#include "llvm/CallingConv.h"
|
2009-08-23 07:05:07 +00:00
|
|
|
#include "llvm/Target/TargetData.h"
|
2009-01-13 15:17:14 +00:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
2008-02-03 02:05:04 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2009-07-11 13:10:19 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2009-08-23 07:05:07 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
static cl::opt<bool>
|
|
|
|
EnableExpensiveChecks("enable-legalize-types-checking", cl::Hidden);
|
|
|
|
|
|
|
|
/// PerformExpensiveChecks - Do extensive, expensive, sanity checking.
|
|
|
|
void DAGTypeLegalizer::PerformExpensiveChecks() {
|
|
|
|
// If a node is not processed, then none of its values should be mapped by any
|
|
|
|
// of PromotedIntegers, ExpandedIntegers, ..., ReplacedValues.
|
|
|
|
|
|
|
|
// If a node is processed, then each value with an illegal type must be mapped
|
|
|
|
// by exactly one of PromotedIntegers, ExpandedIntegers, ..., ReplacedValues.
|
|
|
|
// Values with a legal type may be mapped by ReplacedValues, but not by any of
|
|
|
|
// the other maps.
|
|
|
|
|
|
|
|
// Note that these invariants may not hold momentarily when processing a node:
|
|
|
|
// the node being processed may be put in a map before being marked Processed.
|
|
|
|
|
|
|
|
// Note that it is possible to have nodes marked NewNode in the DAG. This can
|
|
|
|
// occur in two ways. Firstly, a node may be created during legalization but
|
|
|
|
// never passed to the legalization core. This is usually due to the implicit
|
|
|
|
// folding that occurs when using the DAG.getNode operators. Secondly, a new
|
|
|
|
// node may be passed to the legalization core, but when analyzed may morph
|
|
|
|
// into a different node, leaving the original node as a NewNode in the DAG.
|
|
|
|
// A node may morph if one of its operands changes during analysis. Whether
|
|
|
|
// it actually morphs or not depends on whether, after updating its operands,
|
|
|
|
// it is equivalent to an existing node: if so, it morphs into that existing
|
|
|
|
// node (CSE). An operand can change during analysis if the operand is a new
|
|
|
|
// node that morphs, or it is a processed value that was mapped to some other
|
|
|
|
// value (as recorded in ReplacedValues) in which case the operand is turned
|
|
|
|
// into that other value. If a node morphs then the node it morphed into will
|
|
|
|
// be used instead of it for legalization, however the original node continues
|
|
|
|
// to live on in the DAG.
|
|
|
|
// The conclusion is that though there may be nodes marked NewNode in the DAG,
|
|
|
|
// all uses of such nodes are also marked NewNode: the result is a fungus of
|
|
|
|
// NewNodes growing on top of the useful nodes, and perhaps using them, but
|
|
|
|
// not used by them.
|
|
|
|
|
|
|
|
// If a value is mapped by ReplacedValues, then it must have no uses, except
|
|
|
|
// by nodes marked NewNode (see above).
|
|
|
|
|
|
|
|
// The final node obtained by mapping by ReplacedValues is not marked NewNode.
|
|
|
|
// Note that ReplacedValues should be applied iteratively.
|
|
|
|
|
2009-11-20 10:45:10 +00:00
|
|
|
// Note that the ReplacedValues map may also map deleted nodes (by iterating
|
|
|
|
// over the DAG we never dereference deleted nodes). This means that it may
|
|
|
|
// also map nodes marked NewNode if the deallocated memory was reallocated as
|
|
|
|
// another node, and that new node was not seen by the LegalizeTypes machinery
|
|
|
|
// (for example because it was created but not used). In general, we cannot
|
|
|
|
// distinguish between new nodes and deleted nodes.
|
2008-12-09 21:33:20 +00:00
|
|
|
SmallVector<SDNode*, 16> NewNodes;
|
|
|
|
for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(),
|
|
|
|
E = DAG.allnodes_end(); I != E; ++I) {
|
|
|
|
// Remember nodes marked NewNode - they are subject to extra checking below.
|
|
|
|
if (I->getNodeId() == NewNode)
|
|
|
|
NewNodes.push_back(I);
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = I->getNumValues(); i != e; ++i) {
|
|
|
|
SDValue Res(I, i);
|
|
|
|
bool Failed = false;
|
|
|
|
|
|
|
|
unsigned Mapped = 0;
|
|
|
|
if (ReplacedValues.find(Res) != ReplacedValues.end()) {
|
|
|
|
Mapped |= 1;
|
|
|
|
// Check that remapped values are only used by nodes marked NewNode.
|
|
|
|
for (SDNode::use_iterator UI = I->use_begin(), UE = I->use_end();
|
|
|
|
UI != UE; ++UI)
|
2009-01-26 04:35:06 +00:00
|
|
|
if (UI.getUse().getResNo() == i)
|
2008-12-09 21:33:20 +00:00
|
|
|
assert(UI->getNodeId() == NewNode &&
|
|
|
|
"Remapped value has non-trivial use!");
|
|
|
|
|
|
|
|
// Check that the final result of applying ReplacedValues is not
|
|
|
|
// marked NewNode.
|
|
|
|
SDValue NewVal = ReplacedValues[Res];
|
|
|
|
DenseMap<SDValue, SDValue>::iterator I = ReplacedValues.find(NewVal);
|
|
|
|
while (I != ReplacedValues.end()) {
|
|
|
|
NewVal = I->second;
|
|
|
|
I = ReplacedValues.find(NewVal);
|
|
|
|
}
|
|
|
|
assert(NewVal.getNode()->getNodeId() != NewNode &&
|
|
|
|
"ReplacedValues maps to a new node!");
|
|
|
|
}
|
|
|
|
if (PromotedIntegers.find(Res) != PromotedIntegers.end())
|
|
|
|
Mapped |= 2;
|
|
|
|
if (SoftenedFloats.find(Res) != SoftenedFloats.end())
|
|
|
|
Mapped |= 4;
|
|
|
|
if (ScalarizedVectors.find(Res) != ScalarizedVectors.end())
|
|
|
|
Mapped |= 8;
|
|
|
|
if (ExpandedIntegers.find(Res) != ExpandedIntegers.end())
|
|
|
|
Mapped |= 16;
|
|
|
|
if (ExpandedFloats.find(Res) != ExpandedFloats.end())
|
|
|
|
Mapped |= 32;
|
|
|
|
if (SplitVectors.find(Res) != SplitVectors.end())
|
|
|
|
Mapped |= 64;
|
2008-12-18 20:03:17 +00:00
|
|
|
if (WidenedVectors.find(Res) != WidenedVectors.end())
|
|
|
|
Mapped |= 128;
|
2008-12-09 21:33:20 +00:00
|
|
|
|
|
|
|
if (I->getNodeId() != Processed) {
|
2009-11-20 10:45:10 +00:00
|
|
|
// Since we allow ReplacedValues to map deleted nodes, it may map nodes
|
|
|
|
// marked NewNode too, since a deleted node may have been reallocated as
|
|
|
|
// another node that has not been seen by the LegalizeTypes machinery.
|
|
|
|
if ((I->getNodeId() == NewNode && Mapped > 1) ||
|
|
|
|
(I->getNodeId() != NewNode && Mapped != 0)) {
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Unprocessed value in a map!";
|
2008-12-09 21:33:20 +00:00
|
|
|
Failed = true;
|
|
|
|
}
|
2009-05-16 04:14:29 +00:00
|
|
|
} else if (isTypeLegal(Res.getValueType()) || IgnoreNodeResults(I)) {
|
2009-04-27 19:33:03 +00:00
|
|
|
if (Mapped > 1) {
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Value with legal type was transformed!";
|
2008-12-09 21:33:20 +00:00
|
|
|
Failed = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Mapped == 0) {
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Processed value not in any map!";
|
2008-12-09 21:33:20 +00:00
|
|
|
Failed = true;
|
|
|
|
} else if (Mapped & (Mapped - 1)) {
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Value in multiple maps!";
|
2008-12-09 21:33:20 +00:00
|
|
|
Failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Failed) {
|
|
|
|
if (Mapped & 1)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " ReplacedValues";
|
2008-12-09 21:33:20 +00:00
|
|
|
if (Mapped & 2)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " PromotedIntegers";
|
2008-12-09 21:33:20 +00:00
|
|
|
if (Mapped & 4)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " SoftenedFloats";
|
2008-12-09 21:33:20 +00:00
|
|
|
if (Mapped & 8)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " ScalarizedVectors";
|
2008-12-09 21:33:20 +00:00
|
|
|
if (Mapped & 16)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " ExpandedIntegers";
|
2008-12-09 21:33:20 +00:00
|
|
|
if (Mapped & 32)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " ExpandedFloats";
|
2008-12-09 21:33:20 +00:00
|
|
|
if (Mapped & 64)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " SplitVectors";
|
2008-12-18 20:03:17 +00:00
|
|
|
if (Mapped & 128)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << " WidenedVectors";
|
|
|
|
dbgs() << "\n";
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable(0);
|
2008-12-09 21:33:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checked that NewNodes are only used by other NewNodes.
|
|
|
|
for (unsigned i = 0, e = NewNodes.size(); i != e; ++i) {
|
|
|
|
SDNode *N = NewNodes[i];
|
|
|
|
for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end();
|
|
|
|
UI != UE; ++UI)
|
|
|
|
assert(UI->getNodeId() == NewNode && "NewNode used by non-NewNode!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
/// run - This is the main entry point for the type legalizer. This does a
|
2008-11-24 14:53:14 +00:00
|
|
|
/// top-down traversal of the dag, legalizing types as it goes. Returns "true"
|
|
|
|
/// if it made any changes.
|
|
|
|
bool DAGTypeLegalizer::run() {
|
|
|
|
bool Changed = false;
|
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// Create a dummy node (which is not added to allnodes), that adds a reference
|
|
|
|
// to the root node, preventing it from being deleted, and tracking any
|
|
|
|
// changes of the root.
|
|
|
|
HandleSDNode Dummy(DAG.getRoot());
|
2008-12-09 21:33:20 +00:00
|
|
|
Dummy.setNodeId(Unanalyzed);
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
|
|
|
|
// The root of the dag may dangle to deleted nodes until the type legalizer is
|
|
|
|
// done. Set it to null to avoid confusion.
|
2008-07-27 21:46:04 +00:00
|
|
|
DAG.setRoot(SDValue());
|
2008-06-17 14:27:01 +00:00
|
|
|
|
2008-10-29 17:52:12 +00:00
|
|
|
// Walk all nodes in the graph, assigning them a NodeId of 'ReadyToProcess'
|
2008-12-09 21:33:20 +00:00
|
|
|
// (and remembering them) if they are leaves and assigning 'Unanalyzed' if
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// non-leaves.
|
|
|
|
for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(),
|
|
|
|
E = DAG.allnodes_end(); I != E; ++I) {
|
|
|
|
if (I->getNumOperands() == 0) {
|
|
|
|
I->setNodeId(ReadyToProcess);
|
|
|
|
Worklist.push_back(I);
|
|
|
|
} else {
|
2008-12-09 21:33:20 +00:00
|
|
|
I->setNodeId(Unanalyzed);
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-17 14:27:01 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// Now that we have a set of nodes to process, handle them all.
|
|
|
|
while (!Worklist.empty()) {
|
2008-12-09 21:33:20 +00:00
|
|
|
#ifndef XDEBUG
|
|
|
|
if (EnableExpensiveChecks)
|
|
|
|
#endif
|
|
|
|
PerformExpensiveChecks();
|
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
SDNode *N = Worklist.back();
|
|
|
|
Worklist.pop_back();
|
|
|
|
assert(N->getNodeId() == ReadyToProcess &&
|
|
|
|
"Node should be ready if on worklist!");
|
2008-06-17 14:27:01 +00:00
|
|
|
|
2008-07-14 17:15:45 +00:00
|
|
|
if (IgnoreNodeResults(N))
|
|
|
|
goto ScanOperands;
|
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// Scan the values produced by the node, checking to see if any result
|
|
|
|
// types are illegal.
|
2008-07-14 17:15:45 +00:00
|
|
|
for (unsigned i = 0, NumResults = N->getNumValues(); i < NumResults; ++i) {
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT ResultVT = N->getValueType(i);
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
switch (getTypeAction(ResultVT)) {
|
|
|
|
default:
|
|
|
|
assert(false && "Unknown action!");
|
|
|
|
case Legal:
|
|
|
|
break;
|
2008-12-09 21:33:20 +00:00
|
|
|
// The following calls must take care of *all* of the node's results,
|
|
|
|
// not just the illegal result they were passed (this includes results
|
|
|
|
// with a legal type). Results can be remapped using ReplaceValueWith,
|
|
|
|
// or their promoted/expanded/etc values registered in PromotedIntegers,
|
|
|
|
// ExpandedIntegers etc.
|
2008-06-17 14:27:01 +00:00
|
|
|
case PromoteInteger:
|
|
|
|
PromoteIntegerResult(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
goto NodeDone;
|
2008-06-17 14:27:01 +00:00
|
|
|
case ExpandInteger:
|
|
|
|
ExpandIntegerResult(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
goto NodeDone;
|
2008-06-20 17:49:55 +00:00
|
|
|
case SoftenFloat:
|
|
|
|
SoftenFloatResult(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
2008-06-17 14:27:01 +00:00
|
|
|
goto NodeDone;
|
|
|
|
case ExpandFloat:
|
|
|
|
ExpandFloatResult(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
Initial soft-float support for LegalizeTypes. I rewrote
the fcopysign expansion from LegalizeDAG to get rid of
what seems to be a bug: the use of sign extension means
that when copying the sign bit from an f32 to an f64,
the upper 32 bits of the f64 (now an i64) are set, not
just the top bit... I also generalized it to work for
any sized floating point types, and removed the bogosity:
SDOperand Mask1 = (SrcVT == MVT::f64)
? DAG.getConstantFP(BitsToDouble(1ULL << 63), SrcVT)
: DAG.getConstantFP(BitsToFloat(1U << 31), SrcVT);
Mask1 = DAG.getNode(ISD::BIT_CONVERT, SrcNVT, Mask1);
(here SrcNVT is an integer with the same size as SrcVT).
As far as I can see this takes a 1 << 63, converts to
a double, converts that to a floating point constant
then converts that to an integer constant, ending up
with... 1 << 63 as an integer constant! So I just
generate this integer constant directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-12 21:27:04 +00:00
|
|
|
goto NodeDone;
|
2008-07-10 15:25:04 +00:00
|
|
|
case ScalarizeVector:
|
|
|
|
ScalarizeVectorResult(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
goto NodeDone;
|
2008-07-10 15:25:04 +00:00
|
|
|
case SplitVector:
|
|
|
|
SplitVectorResult(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
goto NodeDone;
|
2008-12-18 20:03:17 +00:00
|
|
|
case WidenVector:
|
|
|
|
WidenVectorResult(N, i);
|
|
|
|
Changed = true;
|
|
|
|
goto NodeDone;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
2008-07-14 17:15:45 +00:00
|
|
|
}
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
|
2008-07-14 17:15:45 +00:00
|
|
|
ScanOperands:
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// Scan the operand list for the node, handling any nodes with operands that
|
|
|
|
// are illegal.
|
|
|
|
{
|
|
|
|
unsigned NumOperands = N->getNumOperands();
|
2008-12-09 21:33:20 +00:00
|
|
|
bool NeedsReanalyzing = false;
|
2008-07-14 17:15:45 +00:00
|
|
|
unsigned i;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
for (i = 0; i != NumOperands; ++i) {
|
2008-08-28 21:40:38 +00:00
|
|
|
if (IgnoreNodeResults(N->getOperand(i).getNode()))
|
2008-07-14 17:15:45 +00:00
|
|
|
continue;
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT OpVT = N->getOperand(i).getValueType();
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
switch (getTypeAction(OpVT)) {
|
|
|
|
default:
|
|
|
|
assert(false && "Unknown action!");
|
|
|
|
case Legal:
|
|
|
|
continue;
|
2008-12-09 21:33:20 +00:00
|
|
|
// The following calls must either replace all of the node's results
|
|
|
|
// using ReplaceValueWith, and return "false"; or update the node's
|
|
|
|
// operands in place, and return "true".
|
2008-06-17 14:27:01 +00:00
|
|
|
case PromoteInteger:
|
2008-12-09 21:33:20 +00:00
|
|
|
NeedsReanalyzing = PromoteIntegerOperand(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
2008-06-17 14:27:01 +00:00
|
|
|
break;
|
|
|
|
case ExpandInteger:
|
2008-12-09 21:33:20 +00:00
|
|
|
NeedsReanalyzing = ExpandIntegerOperand(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
break;
|
2008-06-20 17:49:55 +00:00
|
|
|
case SoftenFloat:
|
2008-12-09 21:33:20 +00:00
|
|
|
NeedsReanalyzing = SoftenFloatOperand(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
break;
|
2008-06-17 14:27:01 +00:00
|
|
|
case ExpandFloat:
|
2008-12-09 21:33:20 +00:00
|
|
|
NeedsReanalyzing = ExpandFloatOperand(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
Initial soft-float support for LegalizeTypes. I rewrote
the fcopysign expansion from LegalizeDAG to get rid of
what seems to be a bug: the use of sign extension means
that when copying the sign bit from an f32 to an f64,
the upper 32 bits of the f64 (now an i64) are set, not
just the top bit... I also generalized it to work for
any sized floating point types, and removed the bogosity:
SDOperand Mask1 = (SrcVT == MVT::f64)
? DAG.getConstantFP(BitsToDouble(1ULL << 63), SrcVT)
: DAG.getConstantFP(BitsToFloat(1U << 31), SrcVT);
Mask1 = DAG.getNode(ISD::BIT_CONVERT, SrcNVT, Mask1);
(here SrcNVT is an integer with the same size as SrcVT).
As far as I can see this takes a 1 << 63, converts to
a double, converts that to a floating point constant
then converts that to an integer constant, ending up
with... 1 << 63 as an integer constant! So I just
generate this integer constant directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-12 21:27:04 +00:00
|
|
|
break;
|
2008-07-10 15:25:04 +00:00
|
|
|
case ScalarizeVector:
|
2008-12-09 21:33:20 +00:00
|
|
|
NeedsReanalyzing = ScalarizeVectorOperand(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
break;
|
2008-07-10 15:25:04 +00:00
|
|
|
case SplitVector:
|
2008-12-09 21:33:20 +00:00
|
|
|
NeedsReanalyzing = SplitVectorOperand(N, i);
|
2008-11-24 14:53:14 +00:00
|
|
|
Changed = true;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
break;
|
2008-12-18 20:03:17 +00:00
|
|
|
case WidenVector:
|
|
|
|
NeedsReanalyzing = WidenVectorOperand(N, i);
|
|
|
|
Changed = true;
|
|
|
|
break;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
LegalizeTypes support for EXTRACT_VECTOR_ELT. The
approach taken is different to that in LegalizeDAG
when it is a question of expanding or promoting the
result type: for example, if extracting an i64 from
a <2 x i64>, when i64 needs expanding, it bitcasts
the vector to <4 x i32>, extracts the appropriate
two i32's, and uses those for the Lo and Hi parts.
Likewise, when extracting an i16 from a <4 x i16>,
and i16 needs promoting, it bitcasts the vector to
<2 x i32>, extracts the appropriate i32, twiddles
the bits if necessary, and uses that as the promoted
value. This puts more pressure on bitcast legalization,
and I've added the appropriate cases. They needed to
be added anyway since users can generate such bitcasts
too if they want to. Also, when considering various
cases (Legal, Promote, Expand, Scalarize, Split) it is
a pain that expand can correspond to Expand, Scalarize
or Split, so I've changed the LegalizeTypes enum so it
lists those different cases - now Expand only means
splitting a scalar in two.
The code produced is the same as by LegalizeDAG for
all relevant testcases, except for
2007-10-31-extractelement-i64.ll, where the code seems
to have improved (see below; can an expert please tell
me if it is better or not).
Before < vs after >.
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 28(%esp)
< movl (%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 28(%esp)
< movl 8(%esp), %eax
< movl %eax, 24(%esp)
< movq 24(%esp), %mm0
< movq %mm0, 56(%esp)
---
> subl $44, %esp
> movaps %xmm0, 16(%esp)
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movq (%esp), %mm0
> movq %mm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 16(%esp), %eax
< movl %eax, 48(%esp)
< movl 20(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 4(%esp), %eax
< movl %eax, 60(%esp)
< movl (%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $1, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
< subl $92, %esp
< movaps %xmm0, 64(%esp)
---
> subl $44, %esp
< movl 24(%esp), %eax
< movl %eax, 48(%esp)
< movl 28(%esp), %eax
< movl %eax, 52(%esp)
< movaps %xmm0, (%esp)
< movl 12(%esp), %eax
< movl %eax, 60(%esp)
< movl 8(%esp), %eax
< movl %eax, 56(%esp)
---
> pshufd $3, %xmm0, %xmm1
> movd %xmm1, 4(%esp)
> movhlps %xmm0, %xmm0
> movd %xmm0, (%esp)
> movd %xmm1, 12(%esp)
> movd %xmm0, 8(%esp)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-27 13:34:40 +00:00
|
|
|
break;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
// The sub-method updated N in place. Check to see if any operands are new,
|
|
|
|
// and if so, mark them. If the node needs revisiting, don't add all users
|
|
|
|
// to the worklist etc.
|
|
|
|
if (NeedsReanalyzing) {
|
|
|
|
assert(N->getNodeId() == ReadyToProcess && "Node ID recalculated?");
|
|
|
|
N->setNodeId(NewNode);
|
|
|
|
// Recompute the NodeId and correct processed operands, adding the node to
|
|
|
|
// the worklist if ready.
|
|
|
|
SDNode *M = AnalyzeNewNode(N);
|
|
|
|
if (M == N)
|
|
|
|
// The node didn't morph - nothing special to do, it will be revisited.
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// The node morphed - this is equivalent to legalizing by replacing every
|
2009-11-20 10:45:10 +00:00
|
|
|
// value of N with the corresponding value of M. So do that now.
|
2008-12-09 21:33:20 +00:00
|
|
|
assert(N->getNumValues() == M->getNumValues() &&
|
|
|
|
"Node morphing changed the number of results!");
|
|
|
|
for (unsigned i = 0, e = N->getNumValues(); i != e; ++i)
|
2009-11-20 10:45:10 +00:00
|
|
|
// Replacing the value takes care of remapping the new value.
|
|
|
|
ReplaceValueWith(SDValue(N, i), SDValue(M, i));
|
2009-01-26 21:54:18 +00:00
|
|
|
assert(N->getNodeId() == NewNode && "Unexpected node state!");
|
|
|
|
// The node continues to live on as part of the NewNode fungus that
|
|
|
|
// grows on top of the useful nodes. Nothing more needs to be done
|
|
|
|
// with it - move on to the next node.
|
|
|
|
continue;
|
2008-12-09 21:33:20 +00:00
|
|
|
}
|
2008-06-17 14:27:01 +00:00
|
|
|
|
2008-08-20 14:00:56 +00:00
|
|
|
if (i == NumOperands) {
|
2010-01-05 01:25:04 +00:00
|
|
|
DEBUG(dbgs() << "Legally typed node: "; N->dump(&DAG); dbgs() << "\n");
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
2008-08-20 14:00:56 +00:00
|
|
|
}
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
NodeDone:
|
|
|
|
|
|
|
|
// If we reach here, the node was processed, potentially creating new nodes.
|
|
|
|
// Mark it as processed and add its users to the worklist as appropriate.
|
2008-12-09 21:33:20 +00:00
|
|
|
assert(N->getNodeId() == ReadyToProcess && "Node ID recalculated?");
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
N->setNodeId(Processed);
|
2008-06-17 14:27:01 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end();
|
|
|
|
UI != E; ++UI) {
|
2008-07-27 20:43:25 +00:00
|
|
|
SDNode *User = *UI;
|
2008-10-29 17:52:12 +00:00
|
|
|
int NodeId = User->getNodeId();
|
2008-06-17 14:27:01 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// This node has two options: it can either be a new node or its Node ID
|
|
|
|
// may be a count of the number of operands it has that are not ready.
|
2008-10-29 17:52:12 +00:00
|
|
|
if (NodeId > 0) {
|
|
|
|
User->setNodeId(NodeId-1);
|
2008-06-17 14:27:01 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// If this was the last use it was waiting on, add it to the ready list.
|
2008-10-29 17:52:12 +00:00
|
|
|
if (NodeId-1 == ReadyToProcess)
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
Worklist.push_back(User);
|
|
|
|
continue;
|
|
|
|
}
|
2008-06-17 14:27:01 +00:00
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
// If this is an unreachable new node, then ignore it. If it ever becomes
|
|
|
|
// reachable by being used by a newly created node then it will be handled
|
|
|
|
// by AnalyzeNewNode.
|
|
|
|
if (NodeId == NewNode)
|
|
|
|
continue;
|
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// Otherwise, this node is new: this is the first operand of it that
|
2008-10-29 17:52:12 +00:00
|
|
|
// became ready. Its new NodeId is the number of operands it has minus 1
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// (as this node is now processed).
|
2008-12-09 21:33:20 +00:00
|
|
|
assert(NodeId == Unanalyzed && "Unknown node ID!");
|
|
|
|
User->setNodeId(User->getNumOperands() - 1);
|
2008-06-17 14:27:01 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// If the node only has a single operand, it is now ready.
|
|
|
|
if (User->getNumOperands() == 1)
|
|
|
|
Worklist.push_back(User);
|
|
|
|
}
|
|
|
|
}
|
2008-06-17 14:27:01 +00:00
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
#ifndef XDEBUG
|
|
|
|
if (EnableExpensiveChecks)
|
|
|
|
#endif
|
|
|
|
PerformExpensiveChecks();
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
// If the root changed (e.g. it was a dead load) update the root.
|
|
|
|
DAG.setRoot(Dummy.getValue());
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
|
|
|
|
// Remove dead nodes. This is important to do for cleanliness but also before
|
2008-12-09 21:33:20 +00:00
|
|
|
// the checking loop below. Implicit folding by the DAG.getNode operators and
|
|
|
|
// node morphing can cause unreachable nodes to be around with their flags set
|
|
|
|
// to new.
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
DAG.RemoveDeadNodes();
|
|
|
|
|
|
|
|
// In a debug build, scan all the nodes to make sure we found them all. This
|
|
|
|
// ensures that there are no cycles and that everything got processed.
|
|
|
|
#ifndef NDEBUG
|
|
|
|
for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(),
|
|
|
|
E = DAG.allnodes_end(); I != E; ++I) {
|
2008-02-25 16:21:21 +00:00
|
|
|
bool Failed = false;
|
|
|
|
|
|
|
|
// Check that all result types are legal.
|
2008-07-14 17:15:45 +00:00
|
|
|
if (!IgnoreNodeResults(I))
|
|
|
|
for (unsigned i = 0, NumVals = I->getNumValues(); i < NumVals; ++i)
|
|
|
|
if (!isTypeLegal(I->getValueType(i))) {
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Result type " << i << " illegal!\n";
|
2008-07-14 17:15:45 +00:00
|
|
|
Failed = true;
|
|
|
|
}
|
2008-02-25 16:21:21 +00:00
|
|
|
|
|
|
|
// Check that all operand types are legal.
|
|
|
|
for (unsigned i = 0, NumOps = I->getNumOperands(); i < NumOps; ++i)
|
2008-08-28 21:40:38 +00:00
|
|
|
if (!IgnoreNodeResults(I->getOperand(i).getNode()) &&
|
2008-07-14 17:15:45 +00:00
|
|
|
!isTypeLegal(I->getOperand(i).getValueType())) {
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Operand type " << i << " illegal!\n";
|
2008-02-25 16:21:21 +00:00
|
|
|
Failed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (I->getNodeId() != Processed) {
|
|
|
|
if (I->getNodeId() == NewNode)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "New node not analyzed?\n";
|
2008-12-09 21:33:20 +00:00
|
|
|
else if (I->getNodeId() == Unanalyzed)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Unanalyzed node not noticed?\n";
|
2008-02-25 16:21:21 +00:00
|
|
|
else if (I->getNodeId() > 0)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Operand not processed?\n";
|
2008-02-25 16:21:21 +00:00
|
|
|
else if (I->getNodeId() == ReadyToProcess)
|
2010-01-05 01:25:04 +00:00
|
|
|
dbgs() << "Not added to worklist?\n";
|
2008-02-25 16:21:21 +00:00
|
|
|
Failed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Failed) {
|
2010-01-05 01:25:04 +00:00
|
|
|
I->dump(&DAG); dbgs() << "\n";
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable(0);
|
2008-02-25 16:21:21 +00:00
|
|
|
}
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-11-24 14:53:14 +00:00
|
|
|
|
|
|
|
return Changed;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 11:21:42 +00:00
|
|
|
/// AnalyzeNewNode - The specified node is the root of a subtree of potentially
|
|
|
|
/// new nodes. Correct any processed operands (this may change the node) and
|
2008-10-29 06:42:19 +00:00
|
|
|
/// calculate the NodeId. If the node itself changes to a processed node, it
|
|
|
|
/// is not remapped - the caller needs to take care of this.
|
2008-09-01 15:10:19 +00:00
|
|
|
/// Returns the potentially changed node.
|
2008-10-29 06:42:19 +00:00
|
|
|
SDNode *DAGTypeLegalizer::AnalyzeNewNode(SDNode *N) {
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// If this was an existing node that is already done, we're done.
|
2008-12-09 21:33:20 +00:00
|
|
|
if (N->getNodeId() != NewNode && N->getNodeId() != Unanalyzed)
|
2008-10-29 06:42:19 +00:00
|
|
|
return N;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
|
2008-07-02 09:56:41 +00:00
|
|
|
// Remove any stale map entries.
|
|
|
|
ExpungeNode(N);
|
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// Okay, we know that this node is new. Recursively walk all of its operands
|
|
|
|
// to see if they are new also. The depth of this walk is bounded by the size
|
|
|
|
// of the new tree that was constructed (usually 2-3 nodes), so we don't worry
|
2007-10-15 17:16:12 +00:00
|
|
|
// about revisiting of nodes.
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
//
|
|
|
|
// As we walk the operands, keep track of the number of nodes that are
|
|
|
|
// processed. If non-zero, this will become the new nodeid of this node.
|
2008-12-09 21:33:20 +00:00
|
|
|
// Operands may morph when they are analyzed. If so, the node will be
|
|
|
|
// updated after all operands have been analyzed. Since this is rare,
|
|
|
|
// the code tries to minimize overhead in the non-morphing case.
|
2008-02-26 11:21:42 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SmallVector<SDValue, 8> NewOps;
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
unsigned NumProcessed = 0;
|
|
|
|
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue OrigOp = N->getOperand(i);
|
|
|
|
SDValue Op = OrigOp;
|
2008-02-26 11:21:42 +00:00
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
AnalyzeNewValue(Op); // Op may morph.
|
2008-10-28 09:38:36 +00:00
|
|
|
|
|
|
|
if (Op.getNode()->getNodeId() == Processed)
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
++NumProcessed;
|
2008-02-26 11:21:42 +00:00
|
|
|
|
|
|
|
if (!NewOps.empty()) {
|
|
|
|
// Some previous operand changed. Add this one to the list.
|
|
|
|
NewOps.push_back(Op);
|
|
|
|
} else if (Op != OrigOp) {
|
|
|
|
// This is the first operand to change - add all operands so far.
|
2009-07-31 23:36:06 +00:00
|
|
|
NewOps.insert(NewOps.end(), N->op_begin(), N->op_begin() + i);
|
2008-02-26 11:21:42 +00:00
|
|
|
NewOps.push_back(Op);
|
|
|
|
}
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|
2008-02-26 11:21:42 +00:00
|
|
|
|
|
|
|
// Some operands changed - update the node.
|
2008-10-28 09:38:36 +00:00
|
|
|
if (!NewOps.empty()) {
|
2008-10-29 06:42:19 +00:00
|
|
|
SDNode *M = DAG.UpdateNodeOperands(SDValue(N, 0), &NewOps[0],
|
|
|
|
NewOps.size()).getNode();
|
|
|
|
if (M != N) {
|
2008-12-09 21:33:20 +00:00
|
|
|
// The node morphed into a different node. Normally for this to happen
|
|
|
|
// the original node would have to be marked NewNode. However this can
|
|
|
|
// in theory momentarily not be the case while ReplaceValueWith is doing
|
|
|
|
// its stuff. Mark the original node NewNode to help sanity checking.
|
|
|
|
N->setNodeId(NewNode);
|
|
|
|
if (M->getNodeId() != NewNode && M->getNodeId() != Unanalyzed)
|
2008-10-29 06:42:19 +00:00
|
|
|
// It morphed into a previously analyzed node - nothing more to do.
|
|
|
|
return M;
|
2008-10-27 13:18:32 +00:00
|
|
|
|
2008-10-28 09:38:36 +00:00
|
|
|
// It morphed into a different new node. Do the equivalent of passing
|
2008-12-09 21:33:20 +00:00
|
|
|
// it to AnalyzeNewNode: expunge it and calculate the NodeId. No need
|
|
|
|
// to remap the operands, since they are the same as the operands we
|
|
|
|
// remapped above.
|
2008-10-29 06:42:19 +00:00
|
|
|
N = M;
|
2008-10-28 09:38:36 +00:00
|
|
|
ExpungeNode(N);
|
|
|
|
}
|
|
|
|
}
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
|
2008-10-28 09:38:36 +00:00
|
|
|
// Calculate the NodeId.
|
2008-12-09 21:33:20 +00:00
|
|
|
N->setNodeId(N->getNumOperands() - NumProcessed);
|
2008-10-28 09:38:36 +00:00
|
|
|
if (N->getNodeId() == ReadyToProcess)
|
|
|
|
Worklist.push_back(N);
|
2008-10-29 06:42:19 +00:00
|
|
|
|
|
|
|
return N;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// AnalyzeNewValue - Call AnalyzeNewNode, updating the node in Val if needed.
|
|
|
|
/// If the node changes to a processed node, then remap it.
|
|
|
|
void DAGTypeLegalizer::AnalyzeNewValue(SDValue &Val) {
|
2008-12-09 21:33:20 +00:00
|
|
|
Val.setNode(AnalyzeNewNode(Val.getNode()));
|
|
|
|
if (Val.getNode()->getNodeId() == Processed)
|
|
|
|
// We were passed a processed node, or it morphed into one - remap it.
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(Val);
|
2008-09-01 15:10:19 +00:00
|
|
|
}
|
|
|
|
|
2008-10-29 06:42:19 +00:00
|
|
|
/// ExpungeNode - If N has a bogus mapping in ReplacedValues, eliminate it.
|
2008-07-02 09:56:41 +00:00
|
|
|
/// This can occur when a node is deleted then reallocated as a new node -
|
2008-10-29 06:42:19 +00:00
|
|
|
/// the mapping in ReplacedValues applies to the deleted node, not the new
|
2008-07-02 09:56:41 +00:00
|
|
|
/// one.
|
2008-10-29 06:42:19 +00:00
|
|
|
/// The only map that can have a deleted node as a source is ReplacedValues.
|
2008-07-02 09:56:41 +00:00
|
|
|
/// Other maps can have deleted nodes as targets, but since their looked-up
|
2008-10-29 06:42:19 +00:00
|
|
|
/// values are always immediately remapped using RemapValue, resulting in a
|
|
|
|
/// not-deleted node, this is harmless as long as ReplacedValues/RemapValue
|
2008-07-02 09:56:41 +00:00
|
|
|
/// always performs correct mappings. In order to keep the mapping correct,
|
|
|
|
/// ExpungeNode should be called on any new nodes *before* adding them as
|
2008-10-29 06:42:19 +00:00
|
|
|
/// either source or target to ReplacedValues (which typically means calling
|
2008-07-02 09:56:41 +00:00
|
|
|
/// Expunge when a new node is first seen, since it may no longer be marked
|
2008-10-29 06:42:19 +00:00
|
|
|
/// NewNode by the time it is added to ReplacedValues).
|
2008-07-02 09:56:41 +00:00
|
|
|
void DAGTypeLegalizer::ExpungeNode(SDNode *N) {
|
|
|
|
if (N->getNodeId() != NewNode)
|
2008-06-30 16:43:45 +00:00
|
|
|
return;
|
|
|
|
|
2008-10-29 06:42:19 +00:00
|
|
|
// If N is not remapped by ReplacedValues then there is nothing to do.
|
2008-07-02 09:56:41 +00:00
|
|
|
unsigned i, e;
|
|
|
|
for (i = 0, e = N->getNumValues(); i != e; ++i)
|
2008-10-29 06:42:19 +00:00
|
|
|
if (ReplacedValues.find(SDValue(N, i)) != ReplacedValues.end())
|
2008-07-02 09:56:41 +00:00
|
|
|
break;
|
2008-06-11 11:42:12 +00:00
|
|
|
|
2008-07-02 09:56:41 +00:00
|
|
|
if (i == e)
|
|
|
|
return;
|
2008-06-11 11:42:12 +00:00
|
|
|
|
2008-07-02 09:56:41 +00:00
|
|
|
// Remove N from all maps - this is expensive but rare.
|
2008-06-11 11:42:12 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
for (DenseMap<SDValue, SDValue>::iterator I = PromotedIntegers.begin(),
|
2008-07-02 09:56:41 +00:00
|
|
|
E = PromotedIntegers.end(); I != E; ++I) {
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(I->first.getNode() != N);
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(I->second);
|
2008-07-02 09:56:41 +00:00
|
|
|
}
|
2008-06-11 11:42:12 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
for (DenseMap<SDValue, SDValue>::iterator I = SoftenedFloats.begin(),
|
2008-07-02 09:56:41 +00:00
|
|
|
E = SoftenedFloats.end(); I != E; ++I) {
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(I->first.getNode() != N);
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(I->second);
|
2008-07-02 09:56:41 +00:00
|
|
|
}
|
2008-06-11 11:42:12 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
for (DenseMap<SDValue, SDValue>::iterator I = ScalarizedVectors.begin(),
|
2008-07-02 09:56:41 +00:00
|
|
|
E = ScalarizedVectors.end(); I != E; ++I) {
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(I->first.getNode() != N);
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(I->second);
|
2008-07-02 09:56:41 +00:00
|
|
|
}
|
2008-06-17 14:27:01 +00:00
|
|
|
|
2009-01-13 14:42:39 +00:00
|
|
|
for (DenseMap<SDValue, SDValue>::iterator I = WidenedVectors.begin(),
|
|
|
|
E = WidenedVectors.end(); I != E; ++I) {
|
|
|
|
assert(I->first.getNode() != N);
|
|
|
|
RemapValue(I->second);
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
for (DenseMap<SDValue, std::pair<SDValue, SDValue> >::iterator
|
2008-07-02 09:56:41 +00:00
|
|
|
I = ExpandedIntegers.begin(), E = ExpandedIntegers.end(); I != E; ++I){
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(I->first.getNode() != N);
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(I->second.first);
|
|
|
|
RemapValue(I->second.second);
|
2008-07-02 09:56:41 +00:00
|
|
|
}
|
2008-06-11 11:42:12 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
for (DenseMap<SDValue, std::pair<SDValue, SDValue> >::iterator
|
2008-07-02 09:56:41 +00:00
|
|
|
I = ExpandedFloats.begin(), E = ExpandedFloats.end(); I != E; ++I) {
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(I->first.getNode() != N);
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(I->second.first);
|
|
|
|
RemapValue(I->second.second);
|
2008-07-02 09:56:41 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
for (DenseMap<SDValue, std::pair<SDValue, SDValue> >::iterator
|
2008-07-02 09:56:41 +00:00
|
|
|
I = SplitVectors.begin(), E = SplitVectors.end(); I != E; ++I) {
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(I->first.getNode() != N);
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(I->second.first);
|
|
|
|
RemapValue(I->second.second);
|
2008-06-11 11:42:12 +00:00
|
|
|
}
|
2008-07-02 09:56:41 +00:00
|
|
|
|
2008-10-29 06:42:19 +00:00
|
|
|
for (DenseMap<SDValue, SDValue>::iterator I = ReplacedValues.begin(),
|
|
|
|
E = ReplacedValues.end(); I != E; ++I)
|
|
|
|
RemapValue(I->second);
|
2008-07-02 09:56:41 +00:00
|
|
|
|
|
|
|
for (unsigned i = 0, e = N->getNumValues(); i != e; ++i)
|
2008-10-29 06:42:19 +00:00
|
|
|
ReplacedValues.erase(SDValue(N, i));
|
2008-06-11 11:42:12 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
/// RemapValue - If the specified value was already legalized to another value,
|
|
|
|
/// replace it by that value.
|
|
|
|
void DAGTypeLegalizer::RemapValue(SDValue &N) {
|
|
|
|
DenseMap<SDValue, SDValue>::iterator I = ReplacedValues.find(N);
|
|
|
|
if (I != ReplacedValues.end()) {
|
|
|
|
// Use path compression to speed up future lookups if values get multiply
|
|
|
|
// replaced with other values.
|
|
|
|
RemapValue(I->second);
|
|
|
|
N = I->second;
|
|
|
|
assert(N.getNode()->getNodeId() != NewNode && "Mapped to new node!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
/// NodeUpdateListener - This class is a DAGUpdateListener that listens for
|
|
|
|
/// updates to nodes and recomputes their ready state.
|
2009-10-25 06:33:48 +00:00
|
|
|
class NodeUpdateListener : public SelectionDAG::DAGUpdateListener {
|
2008-12-09 21:33:20 +00:00
|
|
|
DAGTypeLegalizer &DTL;
|
2009-01-13 15:17:14 +00:00
|
|
|
SmallSetVector<SDNode*, 16> &NodesToAnalyze;
|
2008-12-09 21:33:20 +00:00
|
|
|
public:
|
|
|
|
explicit NodeUpdateListener(DAGTypeLegalizer &dtl,
|
2009-01-13 15:17:14 +00:00
|
|
|
SmallSetVector<SDNode*, 16> &nta)
|
|
|
|
: DTL(dtl), NodesToAnalyze(nta) {}
|
2008-12-09 21:33:20 +00:00
|
|
|
|
|
|
|
virtual void NodeDeleted(SDNode *N, SDNode *E) {
|
|
|
|
assert(N->getNodeId() != DAGTypeLegalizer::ReadyToProcess &&
|
|
|
|
N->getNodeId() != DAGTypeLegalizer::Processed &&
|
|
|
|
"Invalid node ID for RAUW deletion!");
|
|
|
|
// It is possible, though rare, for the deleted node N to occur as a
|
|
|
|
// target in a map, so note the replacement N -> E in ReplacedValues.
|
|
|
|
assert(E && "Node not replaced?");
|
|
|
|
DTL.NoteDeletion(N, E);
|
|
|
|
|
|
|
|
// In theory the deleted node could also have been scheduled for analysis.
|
2009-02-03 10:23:33 +00:00
|
|
|
// So remove it from the set of nodes which will be analyzed.
|
2009-01-13 15:17:14 +00:00
|
|
|
NodesToAnalyze.remove(N);
|
2008-12-09 21:33:20 +00:00
|
|
|
|
|
|
|
// In general nothing needs to be done for E, since it didn't change but
|
|
|
|
// only gained new uses. However N -> E was just added to ReplacedValues,
|
|
|
|
// and the result of a ReplacedValues mapping is not allowed to be marked
|
|
|
|
// NewNode. So if E is marked NewNode, then it needs to be analyzed.
|
|
|
|
if (E->getNodeId() == DAGTypeLegalizer::NewNode)
|
2009-01-13 15:17:14 +00:00
|
|
|
NodesToAnalyze.insert(E);
|
2008-12-09 21:33:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void NodeUpdated(SDNode *N) {
|
|
|
|
// Node updates can mean pretty much anything. It is possible that an
|
|
|
|
// operand was set to something already processed (f.e.) in which case
|
|
|
|
// this node could become ready. Recompute its flags.
|
|
|
|
assert(N->getNodeId() != DAGTypeLegalizer::ReadyToProcess &&
|
|
|
|
N->getNodeId() != DAGTypeLegalizer::Processed &&
|
|
|
|
"Invalid node ID for RAUW deletion!");
|
2009-02-03 10:23:33 +00:00
|
|
|
N->setNodeId(DAGTypeLegalizer::NewNode);
|
2009-01-13 15:17:14 +00:00
|
|
|
NodesToAnalyze.insert(N);
|
2008-12-09 21:33:20 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-20 10:45:10 +00:00
|
|
|
/// ReplaceValueWith - The specified value was legalized to the specified other
|
|
|
|
/// value. Update the DAG and NodeIds replacing any uses of From to use To
|
|
|
|
/// instead.
|
|
|
|
void DAGTypeLegalizer::ReplaceValueWith(SDValue From, SDValue To) {
|
2008-12-09 21:33:20 +00:00
|
|
|
assert(From.getNode() != To.getNode() && "Potential legalization loop!");
|
|
|
|
|
|
|
|
// If expansion produced new nodes, make sure they are properly marked.
|
2009-11-20 10:45:10 +00:00
|
|
|
ExpungeNode(From.getNode());
|
2008-12-09 21:33:20 +00:00
|
|
|
AnalyzeNewValue(To); // Expunges To.
|
|
|
|
|
|
|
|
// Anything that used the old node should now use the new one. Note that this
|
|
|
|
// can potentially cause recursive merging.
|
2009-01-13 15:17:14 +00:00
|
|
|
SmallSetVector<SDNode*, 16> NodesToAnalyze;
|
|
|
|
NodeUpdateListener NUL(*this, NodesToAnalyze);
|
2008-12-09 21:33:20 +00:00
|
|
|
DAG.ReplaceAllUsesOfValueWith(From, To, &NUL);
|
|
|
|
|
2009-11-20 10:45:10 +00:00
|
|
|
// The old node may still be present in a map like ExpandedIntegers or
|
|
|
|
// PromotedIntegers. Inform maps about the replacement.
|
|
|
|
ReplacedValues[From] = To;
|
|
|
|
|
2008-12-09 21:33:20 +00:00
|
|
|
// Process the list of nodes that need to be reanalyzed.
|
|
|
|
while (!NodesToAnalyze.empty()) {
|
|
|
|
SDNode *N = NodesToAnalyze.back();
|
|
|
|
NodesToAnalyze.pop_back();
|
2009-02-03 10:23:33 +00:00
|
|
|
if (N->getNodeId() != DAGTypeLegalizer::NewNode)
|
|
|
|
// The node was analyzed while reanalyzing an earlier node - it is safe to
|
|
|
|
// skip. Note that this is not a morphing node - otherwise it would still
|
|
|
|
// be marked NewNode.
|
|
|
|
continue;
|
2008-12-09 21:33:20 +00:00
|
|
|
|
|
|
|
// Analyze the node's operands and recalculate the node ID.
|
|
|
|
SDNode *M = AnalyzeNewNode(N);
|
|
|
|
if (M != N) {
|
|
|
|
// The node morphed into a different node. Make everyone use the new node
|
|
|
|
// instead.
|
|
|
|
assert(M->getNodeId() != NewNode && "Analysis resulted in NewNode!");
|
|
|
|
assert(N->getNumValues() == M->getNumValues() &&
|
|
|
|
"Node morphing changed the number of results!");
|
|
|
|
for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) {
|
|
|
|
SDValue OldVal(N, i);
|
|
|
|
SDValue NewVal(M, i);
|
|
|
|
if (M->getNodeId() == Processed)
|
|
|
|
RemapValue(NewVal);
|
|
|
|
DAG.ReplaceAllUsesOfValueWith(OldVal, NewVal, &NUL);
|
|
|
|
}
|
|
|
|
// The original node continues to exist in the DAG, marked NewNode.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::SetPromotedInteger(SDValue Op, SDValue Result) {
|
2009-08-12 00:36:31 +00:00
|
|
|
assert(Result.getValueType() == TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType()) &&
|
2009-07-08 21:34:03 +00:00
|
|
|
"Invalid type for promoted integer");
|
2008-10-29 06:42:19 +00:00
|
|
|
AnalyzeNewValue(Result);
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue &OpEntry = PromotedIntegers[Op];
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(OpEntry.getNode() == 0 && "Node is already promoted!");
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
OpEntry = Result;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::SetSoftenedFloat(SDValue Op, SDValue Result) {
|
2009-08-12 00:36:31 +00:00
|
|
|
assert(Result.getValueType() == TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType()) &&
|
2009-07-08 21:34:03 +00:00
|
|
|
"Invalid type for softened float");
|
2008-10-29 06:42:19 +00:00
|
|
|
AnalyzeNewValue(Result);
|
Initial soft-float support for LegalizeTypes. I rewrote
the fcopysign expansion from LegalizeDAG to get rid of
what seems to be a bug: the use of sign extension means
that when copying the sign bit from an f32 to an f64,
the upper 32 bits of the f64 (now an i64) are set, not
just the top bit... I also generalized it to work for
any sized floating point types, and removed the bogosity:
SDOperand Mask1 = (SrcVT == MVT::f64)
? DAG.getConstantFP(BitsToDouble(1ULL << 63), SrcVT)
: DAG.getConstantFP(BitsToFloat(1U << 31), SrcVT);
Mask1 = DAG.getNode(ISD::BIT_CONVERT, SrcNVT, Mask1);
(here SrcNVT is an integer with the same size as SrcVT).
As far as I can see this takes a 1 << 63, converts to
a double, converts that to a floating point constant
then converts that to an integer constant, ending up
with... 1 << 63 as an integer constant! So I just
generate this integer constant directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-12 21:27:04 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue &OpEntry = SoftenedFloats[Op];
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(OpEntry.getNode() == 0 && "Node is already converted to integer!");
|
Initial soft-float support for LegalizeTypes. I rewrote
the fcopysign expansion from LegalizeDAG to get rid of
what seems to be a bug: the use of sign extension means
that when copying the sign bit from an f32 to an f64,
the upper 32 bits of the f64 (now an i64) are set, not
just the top bit... I also generalized it to work for
any sized floating point types, and removed the bogosity:
SDOperand Mask1 = (SrcVT == MVT::f64)
? DAG.getConstantFP(BitsToDouble(1ULL << 63), SrcVT)
: DAG.getConstantFP(BitsToFloat(1U << 31), SrcVT);
Mask1 = DAG.getNode(ISD::BIT_CONVERT, SrcNVT, Mask1);
(here SrcNVT is an integer with the same size as SrcVT).
As far as I can see this takes a 1 << 63, converts to
a double, converts that to a floating point constant
then converts that to an integer constant, ending up
with... 1 << 63 as an integer constant! So I just
generate this integer constant directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-12 21:27:04 +00:00
|
|
|
OpEntry = Result;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::SetScalarizedVector(SDValue Op, SDValue Result) {
|
2009-07-08 21:34:03 +00:00
|
|
|
assert(Result.getValueType() == Op.getValueType().getVectorElementType() &&
|
|
|
|
"Invalid type for scalarized vector");
|
2008-10-29 06:42:19 +00:00
|
|
|
AnalyzeNewValue(Result);
|
2008-02-26 11:21:42 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue &OpEntry = ScalarizedVectors[Op];
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(OpEntry.getNode() == 0 && "Node is already scalarized!");
|
2007-12-04 07:29:51 +00:00
|
|
|
OpEntry = Result;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::GetExpandedInteger(SDValue Op, SDValue &Lo,
|
|
|
|
SDValue &Hi) {
|
|
|
|
std::pair<SDValue, SDValue> &Entry = ExpandedIntegers[Op];
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(Entry.first);
|
|
|
|
RemapValue(Entry.second);
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(Entry.first.getNode() && "Operand isn't expanded");
|
2008-06-17 14:27:01 +00:00
|
|
|
Lo = Entry.first;
|
|
|
|
Hi = Entry.second;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::SetExpandedInteger(SDValue Op, SDValue Lo,
|
|
|
|
SDValue Hi) {
|
2009-08-12 00:36:31 +00:00
|
|
|
assert(Lo.getValueType() == TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType()) &&
|
2009-07-08 21:34:03 +00:00
|
|
|
Hi.getValueType() == Lo.getValueType() &&
|
|
|
|
"Invalid type for expanded integer");
|
2008-06-17 14:27:01 +00:00
|
|
|
// Lo/Hi may have been newly allocated, if so, add nodeid's as relevant.
|
2008-10-29 06:42:19 +00:00
|
|
|
AnalyzeNewValue(Lo);
|
|
|
|
AnalyzeNewValue(Hi);
|
2008-06-17 14:27:01 +00:00
|
|
|
|
|
|
|
// Remember that this is the result of the node.
|
2008-07-27 21:46:04 +00:00
|
|
|
std::pair<SDValue, SDValue> &Entry = ExpandedIntegers[Op];
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(Entry.first.getNode() == 0 && "Node already expanded");
|
2008-06-17 14:27:01 +00:00
|
|
|
Entry.first = Lo;
|
|
|
|
Entry.second = Hi;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::GetExpandedFloat(SDValue Op, SDValue &Lo,
|
|
|
|
SDValue &Hi) {
|
|
|
|
std::pair<SDValue, SDValue> &Entry = ExpandedFloats[Op];
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(Entry.first);
|
|
|
|
RemapValue(Entry.second);
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(Entry.first.getNode() && "Operand isn't expanded");
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
Lo = Entry.first;
|
|
|
|
Hi = Entry.second;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::SetExpandedFloat(SDValue Op, SDValue Lo,
|
|
|
|
SDValue Hi) {
|
2009-08-12 00:36:31 +00:00
|
|
|
assert(Lo.getValueType() == TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType()) &&
|
2009-07-08 21:34:03 +00:00
|
|
|
Hi.getValueType() == Lo.getValueType() &&
|
|
|
|
"Invalid type for expanded float");
|
2008-02-26 11:21:42 +00:00
|
|
|
// Lo/Hi may have been newly allocated, if so, add nodeid's as relevant.
|
2008-10-29 06:42:19 +00:00
|
|
|
AnalyzeNewValue(Lo);
|
|
|
|
AnalyzeNewValue(Hi);
|
2008-02-26 11:21:42 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
// Remember that this is the result of the node.
|
2008-07-27 21:46:04 +00:00
|
|
|
std::pair<SDValue, SDValue> &Entry = ExpandedFloats[Op];
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(Entry.first.getNode() == 0 && "Node already expanded");
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
Entry.first = Lo;
|
|
|
|
Entry.second = Hi;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::GetSplitVector(SDValue Op, SDValue &Lo,
|
|
|
|
SDValue &Hi) {
|
|
|
|
std::pair<SDValue, SDValue> &Entry = SplitVectors[Op];
|
2008-10-29 06:42:19 +00:00
|
|
|
RemapValue(Entry.first);
|
|
|
|
RemapValue(Entry.second);
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(Entry.first.getNode() && "Operand isn't split");
|
2007-12-08 22:40:18 +00:00
|
|
|
Lo = Entry.first;
|
|
|
|
Hi = Entry.second;
|
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void DAGTypeLegalizer::SetSplitVector(SDValue Op, SDValue Lo,
|
|
|
|
SDValue Hi) {
|
2009-07-08 21:34:03 +00:00
|
|
|
assert(Lo.getValueType().getVectorElementType() ==
|
|
|
|
Op.getValueType().getVectorElementType() &&
|
|
|
|
2*Lo.getValueType().getVectorNumElements() ==
|
|
|
|
Op.getValueType().getVectorNumElements() &&
|
|
|
|
Hi.getValueType() == Lo.getValueType() &&
|
|
|
|
"Invalid type for split vector");
|
2008-02-26 11:21:42 +00:00
|
|
|
// Lo/Hi may have been newly allocated, if so, add nodeid's as relevant.
|
2008-10-29 06:42:19 +00:00
|
|
|
AnalyzeNewValue(Lo);
|
|
|
|
AnalyzeNewValue(Hi);
|
2008-02-26 11:21:42 +00:00
|
|
|
|
2007-12-08 22:40:18 +00:00
|
|
|
// Remember that this is the result of the node.
|
2008-07-27 21:46:04 +00:00
|
|
|
std::pair<SDValue, SDValue> &Entry = SplitVectors[Op];
|
2008-08-28 21:40:38 +00:00
|
|
|
assert(Entry.first.getNode() == 0 && "Node already split");
|
2007-12-08 22:40:18 +00:00
|
|
|
Entry.first = Lo;
|
|
|
|
Entry.second = Hi;
|
|
|
|
}
|
|
|
|
|
2008-12-18 20:03:17 +00:00
|
|
|
void DAGTypeLegalizer::SetWidenedVector(SDValue Op, SDValue Result) {
|
2009-08-12 00:36:31 +00:00
|
|
|
assert(Result.getValueType() == TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType()) &&
|
2009-07-08 21:34:03 +00:00
|
|
|
"Invalid type for widened vector");
|
2008-12-18 20:03:17 +00:00
|
|
|
AnalyzeNewValue(Result);
|
|
|
|
|
|
|
|
SDValue &OpEntry = WidenedVectors[Op];
|
2009-01-13 14:42:39 +00:00
|
|
|
assert(OpEntry.getNode() == 0 && "Node already widened!");
|
2008-12-18 20:03:17 +00:00
|
|
|
OpEntry = Result;
|
|
|
|
}
|
|
|
|
|
2007-12-08 22:40:18 +00:00
|
|
|
|
2008-06-20 18:40:50 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Utilities.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
Initial soft-float support for LegalizeTypes. I rewrote
the fcopysign expansion from LegalizeDAG to get rid of
what seems to be a bug: the use of sign extension means
that when copying the sign bit from an f32 to an f64,
the upper 32 bits of the f64 (now an i64) are set, not
just the top bit... I also generalized it to work for
any sized floating point types, and removed the bogosity:
SDOperand Mask1 = (SrcVT == MVT::f64)
? DAG.getConstantFP(BitsToDouble(1ULL << 63), SrcVT)
: DAG.getConstantFP(BitsToFloat(1U << 31), SrcVT);
Mask1 = DAG.getNode(ISD::BIT_CONVERT, SrcNVT, Mask1);
(here SrcNVT is an integer with the same size as SrcVT).
As far as I can see this takes a 1 << 63, converts to
a double, converts that to a floating point constant
then converts that to an integer constant, ending up
with... 1 << 63 as an integer constant! So I just
generate this integer constant directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-12 21:27:04 +00:00
|
|
|
/// BitConvertToInteger - Convert to an integer of the same size.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue DAGTypeLegalizer::BitConvertToInteger(SDValue Op) {
|
2008-06-06 12:08:01 +00:00
|
|
|
unsigned BitWidth = Op.getValueType().getSizeInBits();
|
2009-02-07 19:59:05 +00:00
|
|
|
return DAG.getNode(ISD::BIT_CONVERT, Op.getDebugLoc(),
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT::getIntegerVT(*DAG.getContext(), BitWidth), Op);
|
Initial soft-float support for LegalizeTypes. I rewrote
the fcopysign expansion from LegalizeDAG to get rid of
what seems to be a bug: the use of sign extension means
that when copying the sign bit from an f32 to an f64,
the upper 32 bits of the f64 (now an i64) are set, not
just the top bit... I also generalized it to work for
any sized floating point types, and removed the bogosity:
SDOperand Mask1 = (SrcVT == MVT::f64)
? DAG.getConstantFP(BitsToDouble(1ULL << 63), SrcVT)
: DAG.getConstantFP(BitsToFloat(1U << 31), SrcVT);
Mask1 = DAG.getNode(ISD::BIT_CONVERT, SrcNVT, Mask1);
(here SrcNVT is an integer with the same size as SrcVT).
As far as I can see this takes a 1 << 63, converts to
a double, converts that to a floating point constant
then converts that to an integer constant, ending up
with... 1 << 63 as an integer constant! So I just
generate this integer constant directly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48305 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-12 21:27:04 +00:00
|
|
|
}
|
|
|
|
|
2009-03-29 13:51:06 +00:00
|
|
|
/// BitConvertVectorToIntegerVector - Convert to a vector of integers of the
|
|
|
|
/// same size.
|
|
|
|
SDValue DAGTypeLegalizer::BitConvertVectorToIntegerVector(SDValue Op) {
|
|
|
|
assert(Op.getValueType().isVector() && "Only applies to vectors!");
|
|
|
|
unsigned EltWidth = Op.getValueType().getVectorElementType().getSizeInBits();
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT EltNVT = EVT::getIntegerVT(*DAG.getContext(), EltWidth);
|
2009-03-29 13:51:06 +00:00
|
|
|
unsigned NumElts = Op.getValueType().getVectorNumElements();
|
|
|
|
return DAG.getNode(ISD::BIT_CONVERT, Op.getDebugLoc(),
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT::getVectorVT(*DAG.getContext(), EltNVT, NumElts), Op);
|
2009-03-29 13:51:06 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue DAGTypeLegalizer::CreateStackStoreLoad(SDValue Op,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT DestVT) {
|
2009-02-07 19:59:05 +00:00
|
|
|
DebugLoc dl = Op.getDebugLoc();
|
2008-07-10 15:26:17 +00:00
|
|
|
// Create the stack frame object. Make sure it is aligned for both
|
|
|
|
// the source and destination types.
|
2008-12-09 21:33:20 +00:00
|
|
|
SDValue StackPtr = DAG.CreateStackTemporary(Op.getValueType(), DestVT);
|
2007-10-19 03:33:14 +00:00
|
|
|
// Emit a store to the stack slot.
|
2010-02-15 17:00:31 +00:00
|
|
|
SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Op, StackPtr, NULL, 0,
|
|
|
|
false, false, 0);
|
2007-10-19 03:33:14 +00:00
|
|
|
// Result is a load from the stack slot.
|
2010-02-15 17:00:31 +00:00
|
|
|
return DAG.getLoad(DestVT, dl, Store, StackPtr, NULL, 0, false, false, 0);
|
2007-10-19 03:33:14 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 04:15:38 +00:00
|
|
|
/// CustomLowerNode - Replace the node's results with custom code provided
|
2008-12-01 11:39:25 +00:00
|
|
|
/// by the target and return "true", or do nothing and return "false".
|
2009-01-21 09:00:29 +00:00
|
|
|
/// The last parameter is FALSE if we are dealing with a node with legal
|
2009-03-20 09:38:50 +00:00
|
|
|
/// result types and illegal operand. The second parameter denotes the type of
|
|
|
|
/// illegal OperandNo in that case.
|
2009-01-21 04:48:39 +00:00
|
|
|
/// The last parameter being TRUE means we are dealing with a
|
2009-03-20 09:38:50 +00:00
|
|
|
/// node with illegal result types. The second parameter denotes the type of
|
|
|
|
/// illegal ResNo in that case.
|
2009-08-10 22:56:29 +00:00
|
|
|
bool DAGTypeLegalizer::CustomLowerNode(SDNode *N, EVT VT, bool LegalizeResult) {
|
2008-12-01 11:39:25 +00:00
|
|
|
// See if the target wants to custom lower this node.
|
2009-01-21 09:00:29 +00:00
|
|
|
if (TLI.getOperationAction(N->getOpcode(), VT) != TargetLowering::Custom)
|
2008-12-01 11:39:25 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
SmallVector<SDValue, 8> Results;
|
2009-01-21 04:48:39 +00:00
|
|
|
if (LegalizeResult)
|
|
|
|
TLI.ReplaceNodeResults(N, Results, DAG);
|
|
|
|
else
|
2009-01-21 09:00:29 +00:00
|
|
|
TLI.LowerOperationWrapper(N, Results, DAG);
|
2009-01-21 04:48:39 +00:00
|
|
|
|
2008-12-01 11:39:25 +00:00
|
|
|
if (Results.empty())
|
|
|
|
// The target didn't want to custom lower it after all.
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Make everything that once used N's values now use those in Results instead.
|
|
|
|
assert(Results.size() == N->getNumValues() &&
|
|
|
|
"Custom lowering returned the wrong number of results!");
|
|
|
|
for (unsigned i = 0, e = Results.size(); i != e; ++i)
|
|
|
|
ReplaceValueWith(SDValue(N, i), Results[i]);
|
2009-11-30 02:42:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// CustomWidenLowerNode - Widen the node's results with custom code provided
|
|
|
|
/// by the target and return "true", or do nothing and return "false".
|
|
|
|
bool DAGTypeLegalizer::CustomWidenLowerNode(SDNode *N, EVT VT) {
|
|
|
|
// See if the target wants to custom lower this node.
|
|
|
|
if (TLI.getOperationAction(N->getOpcode(), VT) != TargetLowering::Custom)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SmallVector<SDValue, 8> Results;
|
|
|
|
TLI.ReplaceNodeResults(N, Results, DAG);
|
|
|
|
|
|
|
|
if (Results.empty())
|
|
|
|
// The target didn't want to custom widen lower its result after all.
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Update the widening map.
|
|
|
|
assert(Results.size() == N->getNumValues() &&
|
|
|
|
"Custom lowering returned the wrong number of results!");
|
|
|
|
for (unsigned i = 0, e = Results.size(); i != e; ++i)
|
|
|
|
SetWidenedVector(SDValue(N, i), Results[i]);
|
2008-12-01 11:39:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-01 20:36:20 +00:00
|
|
|
/// GetSplitDestVTs - Compute the VTs needed for the low/hi parts of a type
|
|
|
|
/// which is split into two not necessarily identical pieces.
|
2009-08-10 22:56:29 +00:00
|
|
|
void DAGTypeLegalizer::GetSplitDestVTs(EVT InVT, EVT &LoVT, EVT &HiVT) {
|
2009-07-08 21:34:03 +00:00
|
|
|
// Currently all types are split in half.
|
2009-01-01 20:36:20 +00:00
|
|
|
if (!InVT.isVector()) {
|
2009-08-12 00:36:31 +00:00
|
|
|
LoVT = HiVT = TLI.getTypeToTransformTo(*DAG.getContext(), InVT);
|
2009-01-01 20:36:20 +00:00
|
|
|
} else {
|
|
|
|
unsigned NumElements = InVT.getVectorNumElements();
|
2009-07-08 21:34:03 +00:00
|
|
|
assert(!(NumElements & 1) && "Splitting vector, but not in half!");
|
2009-08-12 00:36:31 +00:00
|
|
|
LoVT = HiVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(), NumElements/2);
|
2009-01-01 20:36:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-25 17:55:53 +00:00
|
|
|
/// GetPairElements - Use ISD::EXTRACT_ELEMENT nodes to extract the low and
|
|
|
|
/// high parts of the given value.
|
|
|
|
void DAGTypeLegalizer::GetPairElements(SDValue Pair,
|
|
|
|
SDValue &Lo, SDValue &Hi) {
|
|
|
|
DebugLoc dl = Pair.getDebugLoc();
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Pair.getValueType());
|
2009-04-25 17:55:53 +00:00
|
|
|
Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Pair,
|
|
|
|
DAG.getIntPtrConstant(0));
|
|
|
|
Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Pair,
|
|
|
|
DAG.getIntPtrConstant(1));
|
|
|
|
}
|
|
|
|
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue DAGTypeLegalizer::GetVectorElementPointer(SDValue VecPtr, EVT EltVT,
|
2009-01-01 20:36:20 +00:00
|
|
|
SDValue Index) {
|
2009-02-07 19:59:05 +00:00
|
|
|
DebugLoc dl = Index.getDebugLoc();
|
2009-01-01 20:36:20 +00:00
|
|
|
// Make sure the index type is big enough to compute in.
|
|
|
|
if (Index.getValueType().bitsGT(TLI.getPointerTy()))
|
2009-01-31 20:01:02 +00:00
|
|
|
Index = DAG.getNode(ISD::TRUNCATE, dl, TLI.getPointerTy(), Index);
|
2009-01-01 20:36:20 +00:00
|
|
|
else
|
2009-01-31 20:01:02 +00:00
|
|
|
Index = DAG.getNode(ISD::ZERO_EXTEND, dl, TLI.getPointerTy(), Index);
|
2009-01-01 20:36:20 +00:00
|
|
|
|
|
|
|
// Calculate the element offset and add it to the pointer.
|
2010-02-25 15:20:39 +00:00
|
|
|
unsigned EltSize = EltVT.getSizeInBits() / 8; // FIXME: should be ABI size.
|
2009-01-01 20:36:20 +00:00
|
|
|
|
2009-01-31 20:01:02 +00:00
|
|
|
Index = DAG.getNode(ISD::MUL, dl, Index.getValueType(), Index,
|
2009-01-01 20:36:20 +00:00
|
|
|
DAG.getConstant(EltSize, Index.getValueType()));
|
2009-01-31 20:01:02 +00:00
|
|
|
return DAG.getNode(ISD::ADD, dl, Index.getValueType(), Index, VecPtr);
|
2009-01-01 20:36:20 +00:00
|
|
|
}
|
|
|
|
|
2008-03-11 06:41:14 +00:00
|
|
|
/// JoinIntegers - Build an integer with low bits Lo and high bits Hi.
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue DAGTypeLegalizer::JoinIntegers(SDValue Lo, SDValue Hi) {
|
2009-01-31 20:01:02 +00:00
|
|
|
// Arbitrarily use dlHi for result DebugLoc
|
2009-02-07 19:59:05 +00:00
|
|
|
DebugLoc dlHi = Hi.getDebugLoc();
|
|
|
|
DebugLoc dlLo = Lo.getDebugLoc();
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT LVT = Lo.getValueType();
|
|
|
|
EVT HVT = Hi.getValueType();
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT NVT = EVT::getIntegerVT(*DAG.getContext(), LVT.getSizeInBits() + HVT.getSizeInBits());
|
2008-03-11 06:41:14 +00:00
|
|
|
|
2009-01-31 20:01:02 +00:00
|
|
|
Lo = DAG.getNode(ISD::ZERO_EXTEND, dlLo, NVT, Lo);
|
|
|
|
Hi = DAG.getNode(ISD::ANY_EXTEND, dlHi, NVT, Hi);
|
|
|
|
Hi = DAG.getNode(ISD::SHL, dlHi, NVT, Hi,
|
2009-01-31 15:50:11 +00:00
|
|
|
DAG.getConstant(LVT.getSizeInBits(), TLI.getPointerTy()));
|
2009-01-31 20:01:02 +00:00
|
|
|
return DAG.getNode(ISD::OR, dlHi, NVT, Lo, Hi);
|
2008-03-11 06:41:14 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 20:36:20 +00:00
|
|
|
/// LibCallify - Convert the node into a libcall with the same prototype.
|
|
|
|
SDValue DAGTypeLegalizer::LibCallify(RTLIB::Libcall LC, SDNode *N,
|
|
|
|
bool isSigned) {
|
|
|
|
unsigned NumOps = N->getNumOperands();
|
2009-01-31 00:11:23 +00:00
|
|
|
DebugLoc dl = N->getDebugLoc();
|
2009-01-01 20:36:20 +00:00
|
|
|
if (NumOps == 0) {
|
2009-01-31 00:11:23 +00:00
|
|
|
return MakeLibCall(LC, N->getValueType(0), 0, 0, isSigned, dl);
|
2009-01-01 20:36:20 +00:00
|
|
|
} else if (NumOps == 1) {
|
|
|
|
SDValue Op = N->getOperand(0);
|
2009-01-31 00:11:23 +00:00
|
|
|
return MakeLibCall(LC, N->getValueType(0), &Op, 1, isSigned, dl);
|
2009-01-01 20:36:20 +00:00
|
|
|
} else if (NumOps == 2) {
|
|
|
|
SDValue Ops[2] = { N->getOperand(0), N->getOperand(1) };
|
2009-01-31 00:11:23 +00:00
|
|
|
return MakeLibCall(LC, N->getValueType(0), Ops, 2, isSigned, dl);
|
2009-01-01 20:36:20 +00:00
|
|
|
}
|
|
|
|
SmallVector<SDValue, 8> Ops(NumOps);
|
|
|
|
for (unsigned i = 0; i < NumOps; ++i)
|
|
|
|
Ops[i] = N->getOperand(i);
|
2007-10-22 18:26:21 +00:00
|
|
|
|
2009-01-31 00:11:23 +00:00
|
|
|
return MakeLibCall(LC, N->getValueType(0), &Ops[0], NumOps, isSigned, dl);
|
2008-03-11 06:41:14 +00:00
|
|
|
}
|
2007-10-22 18:26:21 +00:00
|
|
|
|
2008-04-18 20:25:14 +00:00
|
|
|
/// MakeLibCall - Generate a libcall taking the given operands as arguments and
|
|
|
|
/// returning a result of type RetVT.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, EVT RetVT,
|
2008-07-27 21:46:04 +00:00
|
|
|
const SDValue *Ops, unsigned NumOps,
|
2009-01-31 00:11:23 +00:00
|
|
|
bool isSigned, DebugLoc dl) {
|
2008-04-14 06:48:48 +00:00
|
|
|
TargetLowering::ArgListTy Args;
|
2008-04-18 20:25:14 +00:00
|
|
|
Args.reserve(NumOps);
|
|
|
|
|
2008-04-14 06:48:48 +00:00
|
|
|
TargetLowering::ArgListEntry Entry;
|
2008-04-18 20:25:14 +00:00
|
|
|
for (unsigned i = 0; i != NumOps; ++i) {
|
|
|
|
Entry.Node = Ops[i];
|
2009-08-12 00:36:31 +00:00
|
|
|
Entry.Ty = Entry.Node.getValueType().getTypeForEVT(*DAG.getContext());
|
2008-04-14 06:48:48 +00:00
|
|
|
Entry.isSExt = isSigned;
|
|
|
|
Entry.isZExt = !isSigned;
|
|
|
|
Args.push_back(Entry);
|
|
|
|
}
|
2008-09-16 21:48:12 +00:00
|
|
|
SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
|
2008-10-31 14:06:52 +00:00
|
|
|
TLI.getPointerTy());
|
2008-04-14 06:48:48 +00:00
|
|
|
|
2009-08-12 00:36:31 +00:00
|
|
|
const Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
|
2008-07-27 21:46:04 +00:00
|
|
|
std::pair<SDValue,SDValue> CallInfo =
|
2008-04-14 06:48:48 +00:00
|
|
|
TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
|
2009-08-14 20:10:52 +00:00
|
|
|
false, 0, TLI.getLibcallCallingConv(LC), false,
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
/*isReturnValueUsed=*/true,
|
2010-03-02 01:55:18 +00:00
|
|
|
Callee, Args, DAG, dl);
|
2008-04-14 06:48:48 +00:00
|
|
|
return CallInfo.first;
|
|
|
|
}
|
|
|
|
|
2009-01-01 20:36:20 +00:00
|
|
|
/// PromoteTargetBoolean - Promote the given target boolean to a target boolean
|
|
|
|
/// of the given type. A target boolean is an integer value, not necessarily of
|
|
|
|
/// type i1, the bits of which conform to getBooleanContents.
|
2009-08-10 22:56:29 +00:00
|
|
|
SDValue DAGTypeLegalizer::PromoteTargetBoolean(SDValue Bool, EVT VT) {
|
2009-02-07 19:59:05 +00:00
|
|
|
DebugLoc dl = Bool.getDebugLoc();
|
2009-01-01 20:36:20 +00:00
|
|
|
ISD::NodeType ExtendCode;
|
|
|
|
switch (TLI.getBooleanContents()) {
|
|
|
|
default:
|
|
|
|
assert(false && "Unknown BooleanContent!");
|
|
|
|
case TargetLowering::UndefinedBooleanContent:
|
|
|
|
// Extend to VT by adding rubbish bits.
|
|
|
|
ExtendCode = ISD::ANY_EXTEND;
|
|
|
|
break;
|
|
|
|
case TargetLowering::ZeroOrOneBooleanContent:
|
|
|
|
// Extend to VT by adding zero bits.
|
|
|
|
ExtendCode = ISD::ZERO_EXTEND;
|
|
|
|
break;
|
|
|
|
case TargetLowering::ZeroOrNegativeOneBooleanContent: {
|
|
|
|
// Extend to VT by copying the sign bit.
|
|
|
|
ExtendCode = ISD::SIGN_EXTEND;
|
|
|
|
break;
|
2008-10-31 14:06:52 +00:00
|
|
|
}
|
2009-01-01 20:36:20 +00:00
|
|
|
}
|
2009-01-31 20:01:02 +00:00
|
|
|
return DAG.getNode(ExtendCode, dl, VT, Bool);
|
2008-10-31 14:06:52 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 20:36:20 +00:00
|
|
|
/// SplitInteger - Return the lower LoVT bits of Op in Lo and the upper HiVT
|
|
|
|
/// bits in Hi.
|
|
|
|
void DAGTypeLegalizer::SplitInteger(SDValue Op,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT LoVT, EVT HiVT,
|
2009-01-01 20:36:20 +00:00
|
|
|
SDValue &Lo, SDValue &Hi) {
|
2009-02-07 19:59:05 +00:00
|
|
|
DebugLoc dl = Op.getDebugLoc();
|
2009-01-01 20:36:20 +00:00
|
|
|
assert(LoVT.getSizeInBits() + HiVT.getSizeInBits() ==
|
|
|
|
Op.getValueType().getSizeInBits() && "Invalid integer splitting!");
|
2009-01-31 20:01:02 +00:00
|
|
|
Lo = DAG.getNode(ISD::TRUNCATE, dl, LoVT, Op);
|
|
|
|
Hi = DAG.getNode(ISD::SRL, dl, Op.getValueType(), Op,
|
2009-01-31 15:50:11 +00:00
|
|
|
DAG.getConstant(LoVT.getSizeInBits(), TLI.getPointerTy()));
|
2009-01-31 20:01:02 +00:00
|
|
|
Hi = DAG.getNode(ISD::TRUNCATE, dl, HiVT, Hi);
|
2008-06-15 20:00:14 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 20:36:20 +00:00
|
|
|
/// SplitInteger - Return the lower and upper halves of Op's bits in a value
|
|
|
|
/// type half the size of Op's.
|
|
|
|
void DAGTypeLegalizer::SplitInteger(SDValue Op,
|
|
|
|
SDValue &Lo, SDValue &Hi) {
|
2009-08-12 00:36:31 +00:00
|
|
|
EVT HalfVT = EVT::getIntegerVT(*DAG.getContext(), Op.getValueType().getSizeInBits()/2);
|
2009-01-01 20:36:20 +00:00
|
|
|
SplitInteger(Op, HalfVT, HalfVT, Lo, Hi);
|
2008-06-20 18:40:50 +00:00
|
|
|
}
|
|
|
|
|
2008-06-15 20:00:14 +00:00
|
|
|
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Entry Point
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
/// LegalizeTypes - This transforms the SelectionDAG into a SelectionDAG that
|
2008-11-24 14:53:14 +00:00
|
|
|
/// only uses types natively supported by the target. Returns "true" if it made
|
|
|
|
/// any changes.
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
///
|
|
|
|
/// Note that this is an involved process that may invalidate pointers into
|
|
|
|
/// the graph.
|
2008-11-24 14:53:14 +00:00
|
|
|
bool SelectionDAG::LegalizeTypes() {
|
|
|
|
return DAGTypeLegalizer(*this).run();
|
One mundane change: Change ReplaceAllUsesOfValueWith to *optionally*
take a deleted nodes vector, instead of requiring it.
One more significant change: Implement the start of a legalizer that
just works on types. This legalizer is designed to run before the
operation legalizer and ensure just that the input dag is transformed
into an output dag whose operand and result types are all legal, even
if the operations on those types are not.
This design/impl has the following advantages:
1. When finished, this will *significantly* reduce the amount of code in
LegalizeDAG.cpp. It will remove all the code related to promotion and
expansion as well as splitting and scalarizing vectors.
2. The new code is very simple, idiomatic, and modular: unlike
LegalizeDAG.cpp, it has no 3000 line long functions. :)
3. The implementation is completely iterative instead of recursive, good
for hacking on large dags without blowing out your stack.
4. The implementation updates nodes in place when possible instead of
deallocating and reallocating the entire graph that points to some
mutated node.
5. The code nicely separates out handling of operations with invalid
results from operations with invalid operands, making some cases
simpler and easier to understand.
6. The new -debug-only=legalize-types option is very very handy :),
allowing you to easily understand what legalize types is doing.
This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is
enabled, this does nothing. However, this code is sufficient to legalize
all of the code in 186.crafty, olden and freebench on an x86 machine. The
biggest issues are:
1. Vectors aren't implemented at all yet
2. SoftFP is a mess, I need to talk to Evan about it.
3. No lowering to libcalls is implemented yet.
4. Various operations are missing etc.
5. There are FIXME's for stuff I hax0r'd out, like softfp.
Hey, at least it is a step in the right direction :). If you'd like to help,
just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If
this explodes it will tell you what needs to be implemented. Help is
certainly appreciated.
Once this goes in, we can do three things:
1. Add a new pass of dag combine between the "type legalizer" and "operation
legalizer" passes. This will let us catch some long-standing isel issues
that we miss because operation legalization often obfuscates the dag with
target-specific nodes.
2. We can rip out all of the type legalization code from LegalizeDAG.cpp,
making it much smaller and simpler. When that happens we can then
reimplement the core functionality left in it in a much more efficient and
non-recursive way.
3. Once the whole legalizer is non-recursive, we can implement whole-function
selectiondags maybe...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 06:10:22 +00:00
|
|
|
}
|