Skip to content

Commit

Permalink
Add support for the Arg1 argument type
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7747 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Aug 11, 2003
1 parent d59414f commit 88118bf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
17 changes: 14 additions & 3 deletions support/tools/TableGen/InstrSelectorEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NodeType::ArgResultTypes NodeType::Translate(Record *R) {
if (Name == "DNVT_void") return Void;
if (Name == "DNVT_val" ) return Val;
if (Name == "DNVT_arg0") return Arg0;
if (Name == "DNVT_arg1") return Arg1;
if (Name == "DNVT_ptr" ) return Ptr;
throw "Unknown DagNodeValType '" + Name + "'!";
}
Expand Down Expand Up @@ -277,6 +278,10 @@ bool Pattern::InferTypes(TreePatternNode *N, bool &MadeChange) {
MadeChange |= Child->updateNodeType(N->getChild(0)->getType(),
TheRecord->getName());
break;
case NodeType::Arg1:
MadeChange |= Child->updateNodeType(N->getChild(1)->getType(),
TheRecord->getName());
break;
case NodeType::Val:
if (Child->getType() == MVT::isVoid)
error("Inferred a void node in an illegal place!");
Expand All @@ -298,7 +303,10 @@ bool Pattern::InferTypes(TreePatternNode *N, bool &MadeChange) {
MadeChange |= N->updateNodeType(N->getChild(0)->getType(),
TheRecord->getName());
break;

case NodeType::Arg1:
MadeChange |= N->updateNodeType(N->getChild(1)->getType(),
TheRecord->getName());
break;
case NodeType::Ptr:
MadeChange |= N->updateNodeType(ISE.getTarget().getPointerType(),
TheRecord->getName());
Expand Down Expand Up @@ -426,12 +434,15 @@ void InstrSelectorEmitter::ReadNodeTypes() {

if (a == 0 && ArgTypes.back() == NodeType::Arg0)
throw "In node " + Node->getName() + ", arg 0 cannot have type 'arg0'!";
if (a == 1 && ArgTypes.back() == NodeType::Arg1)
throw "In node " + Node->getName() + ", arg 1 cannot have type 'arg1'!";
if (ArgTypes.back() == NodeType::Void)
throw "In node " + Node->getName() + ", args cannot be void type!";
}
if (RetTy == NodeType::Arg0 && Args->getSize() == 0)
if ((RetTy == NodeType::Arg0 && Args->getSize() == 0) ||
(RetTy == NodeType::Arg1 && Args->getSize() < 2))
throw "In node " + Node->getName() +
", invalid return type for nullary node!";
", invalid return type for node with this many operands!";

// Add the node type mapping now...
NodeTypes[Node] = NodeType(RetTy, ArgTypes);
Expand Down
1 change: 1 addition & 0 deletions support/tools/TableGen/InstrSelectorEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct NodeType {
// Both argument and return types...
Val, // A non-void type
Arg0, // Value matches the type of Arg0
Arg1, // Value matches the type of Arg1
Ptr, // Tree node is the type of the target pointer

// Return types
Expand Down
17 changes: 14 additions & 3 deletions utils/TableGen/InstrSelectorEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NodeType::ArgResultTypes NodeType::Translate(Record *R) {
if (Name == "DNVT_void") return Void;
if (Name == "DNVT_val" ) return Val;
if (Name == "DNVT_arg0") return Arg0;
if (Name == "DNVT_arg1") return Arg1;
if (Name == "DNVT_ptr" ) return Ptr;
throw "Unknown DagNodeValType '" + Name + "'!";
}
Expand Down Expand Up @@ -277,6 +278,10 @@ bool Pattern::InferTypes(TreePatternNode *N, bool &MadeChange) {
MadeChange |= Child->updateNodeType(N->getChild(0)->getType(),
TheRecord->getName());
break;
case NodeType::Arg1:
MadeChange |= Child->updateNodeType(N->getChild(1)->getType(),
TheRecord->getName());
break;
case NodeType::Val:
if (Child->getType() == MVT::isVoid)
error("Inferred a void node in an illegal place!");
Expand All @@ -298,7 +303,10 @@ bool Pattern::InferTypes(TreePatternNode *N, bool &MadeChange) {
MadeChange |= N->updateNodeType(N->getChild(0)->getType(),
TheRecord->getName());
break;

case NodeType::Arg1:
MadeChange |= N->updateNodeType(N->getChild(1)->getType(),
TheRecord->getName());
break;
case NodeType::Ptr:
MadeChange |= N->updateNodeType(ISE.getTarget().getPointerType(),
TheRecord->getName());
Expand Down Expand Up @@ -426,12 +434,15 @@ void InstrSelectorEmitter::ReadNodeTypes() {

if (a == 0 && ArgTypes.back() == NodeType::Arg0)
throw "In node " + Node->getName() + ", arg 0 cannot have type 'arg0'!";
if (a == 1 && ArgTypes.back() == NodeType::Arg1)
throw "In node " + Node->getName() + ", arg 1 cannot have type 'arg1'!";
if (ArgTypes.back() == NodeType::Void)
throw "In node " + Node->getName() + ", args cannot be void type!";
}
if (RetTy == NodeType::Arg0 && Args->getSize() == 0)
if ((RetTy == NodeType::Arg0 && Args->getSize() == 0) ||
(RetTy == NodeType::Arg1 && Args->getSize() < 2))
throw "In node " + Node->getName() +
", invalid return type for nullary node!";
", invalid return type for node with this many operands!";

// Add the node type mapping now...
NodeTypes[Node] = NodeType(RetTy, ArgTypes);
Expand Down
1 change: 1 addition & 0 deletions utils/TableGen/InstrSelectorEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct NodeType {
// Both argument and return types...
Val, // A non-void type
Arg0, // Value matches the type of Arg0
Arg1, // Value matches the type of Arg1
Ptr, // Tree node is the type of the target pointer

// Return types
Expand Down

0 comments on commit 88118bf

Please sign in to comment.