From sabre at nondot.org Mon Feb 15 00:38:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 06:38:42 -0000 Subject: [llvm-commits] [llvm] r96212 - /llvm/trunk/lib/Target/XCore/XCoreISelLowering.h Message-ID: <201002150638.o1F6choM027089@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 00:38:41 2010 New Revision: 96212 URL: http://llvm.org/viewvc/llvm-project?rev=96212&view=rev Log: no need to add the instruction count anymore. Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.h Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.h?rev=96212&r1=96211&r2=96212&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.h (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.h Mon Feb 15 00:38:41 2010 @@ -28,7 +28,7 @@ namespace XCoreISD { enum NodeType { // Start the numbering where the builtin ops and target ops leave off. - FIRST_NUMBER = ISD::BUILTIN_OP_END+XCore::INSTRUCTION_LIST_END, + FIRST_NUMBER = ISD::BUILTIN_OP_END, // Branch and link (call) BL, From sabre at nondot.org Mon Feb 15 00:39:31 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 06:39:31 -0000 Subject: [llvm-commits] [llvm] r96213 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <201002150639.o1F6dWDc027128@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 00:39:31 2010 New Revision: 96213 URL: http://llvm.org/viewvc/llvm-project?rev=96213&view=rev Log: don't make insanely large node numbers for no reason, packing somewhat densely is better than not. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=96213&r1=96212&r2=96213&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon Feb 15 00:39:31 2010 @@ -609,7 +609,7 @@ /// which do not reference a specific memory location should be less than /// this value. Those that do must not be less than this value, and can /// be used with SelectionDAG::getMemIntrinsicNode. - static const int FIRST_TARGET_MEMORY_OPCODE = 1 << 14; + static const int FIRST_TARGET_MEMORY_OPCODE = BUILTIN_OP_END+80; /// Node predicates From sabre at nondot.org Mon Feb 15 01:11:35 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 07:11:35 -0000 Subject: [llvm-commits] [llvm] r96214 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Message-ID: <201002150711.o1F7BZiY028560@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 01:11:34 2010 New Revision: 96214 URL: http://llvm.org/viewvc/llvm-project?rev=96214&view=rev Log: give SDValue an operator->, allowing V->isTargetOpcode() and many other natural things. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=96214&r1=96213&r2=96214&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon Feb 15 01:11:34 2010 @@ -821,6 +821,8 @@ /// set the SDNode void setNode(SDNode *N) { Node = N; } + inline SDNode *operator->() const { return Node; } + bool operator==(const SDValue &O) const { return Node == O.Node && ResNo == O.ResNo; } From sabre at nondot.org Mon Feb 15 02:04:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 08:04:42 -0000 Subject: [llvm-commits] [llvm] r96215 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/CMakeLists.txt utils/TableGen/DAGISelEmitter.cpp utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002150804.o1F84g4s030949@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 02:04:42 2010 New Revision: 96215 URL: http://llvm.org/viewvc/llvm-project?rev=96215&view=rev Log: Check in the first big step of rewriting DAGISelEmitter to produce a table based matcher instead of gobs of C++ Code. Though it's not done yet, the shrinkage seems promising, the table for the X86 ISel is 75K and still has a lot of optimization to come (compare to the ~1.5M of .o generated the old way, much of which will go away). The code is currently disabled by default (the #if 0 in DAGISelEmitter.cpp). When enabled it generates a dead SelectCode2 function in the DAGISel Header which will eventually replace SelectCode. There is still a lot of stuff left to do, which are documented with a trail of FIXMEs. Added: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/utils/TableGen/CMakeLists.txt llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96215&r1=96214&r2=96215&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Mon Feb 15 02:04:42 2010 @@ -132,4 +132,268 @@ CurDAG->setRoot(Dummy.getValue()); } + +/// CheckInteger - Return true if the specified node is not a ConstantSDNode or +/// if it doesn't have the specified value. +static bool CheckInteger(SDValue V, int64_t Val) { + ConstantSDNode *C = dyn_cast(V); + return C == 0 || C->getSExtValue() != Val; +} + +/// CheckAndImmediate - Check to see if the specified node is an and with an +/// immediate returning true on failure. +/// +/// FIXME: Inline this gunk into CheckAndMask. +bool CheckAndImmediate(SDValue V, int64_t Val) { + if (V->getOpcode() == ISD::AND) + if (ConstantSDNode *C = dyn_cast(V->getOperand(1))) + if (CheckAndMask(V.getOperand(0), C, Val)) + return false; + return true; +} + +/// CheckOrImmediate - Check to see if the specified node is an or with an +/// immediate returning true on failure. +/// +/// FIXME: Inline this gunk into CheckOrMask. +bool CheckOrImmediate(SDValue V, int64_t Val) { + if (V->getOpcode() == ISD::OR) + if (ConstantSDNode *C = dyn_cast(V->getOperand(1))) + if (CheckOrMask(V.getOperand(0), C, Val)) + return false; + return true; +} + +static int8_t GetInt1(const unsigned char *MatcherTable, unsigned &Idx) { + return MatcherTable[Idx++]; +} + +static int16_t GetInt2(const unsigned char *MatcherTable, unsigned &Idx) { + int16_t Val = GetInt1(MatcherTable, Idx); + Val |= int16_t(GetInt1(MatcherTable, Idx)) << 8; + return Val; +} + +static int32_t GetInt4(const unsigned char *MatcherTable, unsigned &Idx) { + int32_t Val = GetInt2(MatcherTable, Idx); + Val |= int32_t(GetInt2(MatcherTable, Idx)) << 16; + return Val; +} + +static int64_t GetInt8(const unsigned char *MatcherTable, unsigned &Idx) { + int64_t Val = GetInt4(MatcherTable, Idx); + Val |= int64_t(GetInt4(MatcherTable, Idx)) << 32; + return Val; +} + +enum BuiltinOpcodes { + OPC_Emit, + OPC_Push, + OPC_Record, + OPC_MoveChild, + OPC_MoveParent, + OPC_CheckSame, + OPC_CheckPatternPredicate, + OPC_CheckPredicate, + OPC_CheckOpcode, + OPC_CheckType, + OPC_CheckInteger1, OPC_CheckInteger2, OPC_CheckInteger4, OPC_CheckInteger8, + OPC_CheckCondCode, + OPC_CheckValueType, + OPC_CheckComplexPat, + OPC_CheckAndImm1, OPC_CheckAndImm2, OPC_CheckAndImm4, OPC_CheckAndImm8, + OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8 +}; + +struct MatchScope { + /// FailIndex - If this match fails, this is the index to continue with. + unsigned FailIndex; + + /// NodeStackSize - The size of the node stack when the scope was formed. + unsigned NodeStackSize; + + /// NumRecordedNodes - The number of recorded nodes when the scope was formed. + unsigned NumRecordedNodes; +}; + +SDNode *SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable, + unsigned TableSize) { + switch (NodeToMatch->getOpcode()) { + default: + break; + case ISD::EntryToken: // These nodes remain the same. + case ISD::BasicBlock: + case ISD::Register: + case ISD::HANDLENODE: + case ISD::TargetConstant: + case ISD::TargetConstantFP: + case ISD::TargetConstantPool: + case ISD::TargetFrameIndex: + case ISD::TargetExternalSymbol: + case ISD::TargetBlockAddress: + case ISD::TargetJumpTable: + case ISD::TargetGlobalTLSAddress: + case ISD::TargetGlobalAddress: + case ISD::TokenFactor: + case ISD::CopyFromReg: + case ISD::CopyToReg: + return 0; + case ISD::AssertSext: + case ISD::AssertZext: + ReplaceUses(SDValue(NodeToMatch, 0), NodeToMatch->getOperand(0)); + return 0; + case ISD::INLINEASM: return Select_INLINEASM(NodeToMatch); + case ISD::EH_LABEL: return Select_EH_LABEL(NodeToMatch); + case ISD::UNDEF: return Select_UNDEF(NodeToMatch); + } + + assert(!NodeToMatch->isMachineOpcode() && "Node already selected!"); + + SmallVector MatchScopes; + + // RecordedNodes - This is the set of nodes that have been recorded by the + // state machine. + SmallVector RecordedNodes; + + // Set up the node stack with NodeToMatch as the only node on the stack. + SmallVector NodeStack; + SDValue N = SDValue(NodeToMatch, 0); + NodeStack.push_back(N); + + // Interpreter starts at opcode #0. + unsigned MatcherIndex = 0; + while (1) { + assert(MatcherIndex < TableSize && "Invalid index"); + switch ((BuiltinOpcodes)MatcherTable[MatcherIndex++]) { + case OPC_Emit: { + errs() << "EMIT NODE\n"; + return 0; + } + case OPC_Push: { + unsigned NumToSkip = MatcherTable[MatcherIndex++]; + MatchScope NewEntry; + NewEntry.FailIndex = MatcherIndex+NumToSkip; + NewEntry.NodeStackSize = NodeStack.size(); + NewEntry.NumRecordedNodes = RecordedNodes.size(); + MatchScopes.push_back(NewEntry); + continue; + } + case OPC_Record: + // Remember this node, it may end up being an operand in the pattern. + RecordedNodes.push_back(N); + continue; + + case OPC_MoveChild: { + unsigned Child = MatcherTable[MatcherIndex++]; + if (Child >= N.getNumOperands()) + break; // Match fails if out of range child #. + N = N.getOperand(Child); + NodeStack.push_back(N); + continue; + } + + case OPC_MoveParent: + // Pop the current node off the NodeStack. + NodeStack.pop_back(); + assert(!NodeStack.empty() && "Node stack imbalance!"); + N = NodeStack.back(); + continue; + + case OPC_CheckSame: { + // Accept if it is exactly the same as a previously recorded node. + unsigned RecNo = MatcherTable[MatcherIndex++]; + assert(RecNo < RecordedNodes.size() && "Invalid CheckSame"); + if (N != RecordedNodes[RecNo]) break; + continue; + } + case OPC_CheckPatternPredicate: { + unsigned PredNo = MatcherTable[MatcherIndex++]; + (void)PredNo; + // FIXME: CHECK IT. + continue; + } + case OPC_CheckPredicate: { + unsigned PredNo = MatcherTable[MatcherIndex++]; + (void)PredNo; + // FIXME: CHECK IT. + continue; + } + case OPC_CheckComplexPat: { + unsigned PatNo = MatcherTable[MatcherIndex++]; + (void)PatNo; + // FIXME: CHECK IT. + continue; + } + + case OPC_CheckOpcode: + if (N->getOpcode() != MatcherTable[MatcherIndex++]) break; + continue; + case OPC_CheckType: + if (N.getValueType() != + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]) break; + continue; + case OPC_CheckCondCode: + if (cast(N)->get() != + (ISD::CondCode)MatcherTable[MatcherIndex++]) break; + continue; + case OPC_CheckValueType: + if (cast(N)->getVT() != + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]) break; + continue; + + case OPC_CheckInteger1: + if (CheckInteger(N, GetInt1(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckInteger2: + if (CheckInteger(N, GetInt2(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckInteger4: + if (CheckInteger(N, GetInt4(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckInteger8: + if (CheckInteger(N, GetInt8(MatcherTable, MatcherIndex))) break; + continue; + + case OPC_CheckAndImm1: + if (CheckAndImmediate(N, GetInt1(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckAndImm2: + if (CheckAndImmediate(N, GetInt2(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckAndImm4: + if (CheckAndImmediate(N, GetInt4(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckAndImm8: + if (CheckAndImmediate(N, GetInt8(MatcherTable, MatcherIndex))) break; + continue; + + case OPC_CheckOrImm1: + if (CheckOrImmediate(N, GetInt1(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckOrImm2: + if (CheckOrImmediate(N, GetInt2(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckOrImm4: + if (CheckOrImmediate(N, GetInt4(MatcherTable, MatcherIndex))) break; + continue; + case OPC_CheckOrImm8: + if (CheckOrImmediate(N, GetInt8(MatcherTable, MatcherIndex))) break; + continue; + } + + // If the code reached this point, then the match failed pop out to the next + // match scope. + if (MatchScopes.empty()) { + CannotYetSelect(NodeToMatch); + return 0; + } + + RecordedNodes.resize(MatchScopes.back().NumRecordedNodes); + NodeStack.resize(MatchScopes.back().NodeStackSize); + MatcherIndex = MatchScopes.back().FailIndex; + MatchScopes.pop_back(); + } +} + + #endif /* LLVM_CODEGEN_DAGISEL_HEADER_H */ Modified: llvm/trunk/utils/TableGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CMakeLists.txt?rev=96215&r1=96214&r2=96215&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CMakeLists.txt (original) +++ llvm/trunk/utils/TableGen/CMakeLists.txt Mon Feb 15 02:04:42 2010 @@ -9,6 +9,9 @@ CodeGenInstruction.cpp CodeGenTarget.cpp DAGISelEmitter.cpp + DAGISelMatcherEmitter.cpp + DAGISelMatcherGen.cpp + DAGISelMatcher.cpp DisassemblerEmitter.cpp EDEmitter.cpp FastISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96215&r1=96214&r2=96215&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Mon Feb 15 02:04:42 2010 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "DAGISelEmitter.h" +#include "DAGISelMatcher.h" #include "Record.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" @@ -1609,7 +1610,7 @@ void DAGISelEmitter::EmitInstructionSelector(raw_ostream &OS) { const CodeGenTarget &Target = CGP.getTargetInfo(); - + // Get the namespace to insert instructions into. std::string InstNS = Target.getInstNamespace(); if (!InstNS.empty()) InstNS += "::"; @@ -1621,7 +1622,6 @@ for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), E = CGP.ptm_end(); I != E; ++I) { const PatternToMatch &Pattern = *I; - TreePatternNode *Node = Pattern.getSrcPattern(); if (!Node->isLeaf()) { PatternsByOpcode[getOpcodeName(Node->getOperator(), CGP)]. @@ -2011,4 +2011,26 @@ // definitions. Emit the resultant instruction selector. EmitInstructionSelector(OS); +#if 0 + MatcherNode *Matcher = 0; + // Walk the patterns backwards, building a matcher for each and adding it to + // the matcher for the whole target. + for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), + E = CGP.ptm_end(); I != E;) { + const PatternToMatch &Pattern = *--E; + MatcherNode *N = ConvertPatternToMatcher(Pattern, CGP); + + if (Matcher == 0) + Matcher = N; + else + Matcher = new PushMatcherNode(N, Matcher); + } + + + EmitMatcherTable(Matcher, OS); + + + //Matcher->dump(); + delete Matcher; +#endif } Added: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96215&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (added) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Mon Feb 15 02:04:42 2010 @@ -0,0 +1,108 @@ +//===- DAGISelMatcher.cpp - Representation of DAG pattern matcher ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "DAGISelMatcher.h" +#include "CodeGenDAGPatterns.h" +#include "CodeGenTarget.h" +#include "llvm/Support/raw_ostream.h" +using namespace llvm; + +void MatcherNode::dump() const { + print(errs()); +} + +void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "EmitNode: Src = " << *Pattern.getSrcPattern() << "\n"; + OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n"; +} + +void MatcherNodeWithChild::printChild(raw_ostream &OS, unsigned indent) const { + if (Child) + return Child->print(OS, indent); + OS.indent(indent) << "\n"; +} + + +void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "Push\n"; + printChild(OS, indent+2); + Failure->print(OS, indent); +} + +void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "Record\n"; + printChild(OS, indent); +} + +void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "MoveChild " << ChildNo << '\n'; + printChild(OS, indent); +} + +void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "MoveParent\n"; + printChild(OS, indent); +} + +void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; + printChild(OS, indent); +} + +void CheckPatternPredicateMatcherNode:: +print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n'; + printChild(OS, indent); +} + +void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckPredicate " << PredName << '\n'; + printChild(OS, indent); +} + +void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n'; + printChild(OS, indent); +} + +void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n'; + printChild(OS, indent); +} + +void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckInteger " << Value << '\n'; + printChild(OS, indent); +} + +void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; + printChild(OS, indent); +} + +void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n'; + printChild(OS, indent); +} + +void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; + printChild(OS, indent); +} + +void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckAndImm " << Value << '\n'; + printChild(OS, indent); +} + +void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "CheckOrImm " << Value << '\n'; + printChild(OS, indent); +} + Added: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96215&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (added) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Mon Feb 15 02:04:42 2010 @@ -0,0 +1,362 @@ +//===- DAGISelMatcher.h - Representation of DAG pattern matcher -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef TBLGEN_DAGISELMATCHER_H +#define TBLGEN_DAGISELMATCHER_H + +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/CodeGen/ValueTypes.h" + +namespace llvm { + class CodeGenDAGPatterns; + class MatcherNode; + class PatternToMatch; + class raw_ostream; + class ComplexPattern; + +MatcherNode *ConvertPatternToMatcher(const PatternToMatch &Pattern, + const CodeGenDAGPatterns &CGP); + +void EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &OS); + + +/// MatcherNode - Base class for all the the DAG ISel Matcher representation +/// nodes. +class MatcherNode { +public: + enum KindTy { + EmitNode, + Push, // [Push, Dest0, Dest1, Dest2, Dest3] + Record, // [Record] + MoveChild, // [MoveChild, Child#] + MoveParent, // [MoveParent] + + CheckSame, // [CheckSame, N] Fail if not same as prev match. + CheckPatternPredicate, + CheckPredicate, // [CheckPredicate, P] Fail if predicate fails. + CheckOpcode, // [CheckOpcode, Opcode] Fail if not opcode. + CheckType, // [CheckType, MVT] Fail if not correct type. + CheckInteger, // [CheckInteger, int0,int1,int2,...int7] Fail if wrong val. + CheckCondCode, // [CheckCondCode, CondCode] Fail if not condcode. + CheckValueType, + CheckComplexPat, + CheckAndImm, + CheckOrImm + }; + const KindTy Kind; + +protected: + MatcherNode(KindTy K) : Kind(K) {} +public: + virtual ~MatcherNode() {} + + KindTy getKind() const { return Kind; } + + + static inline bool classof(const MatcherNode *) { return true; } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0; + void dump() const; +}; + +/// EmitNodeMatcherNode - This signals a successful match and generates a node. +class EmitNodeMatcherNode : public MatcherNode { + const PatternToMatch &Pattern; +public: + EmitNodeMatcherNode(const PatternToMatch &pattern) + : MatcherNode(EmitNode), Pattern(pattern) {} + + const PatternToMatch &getPattern() const { return Pattern; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == EmitNode; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// MatcherNodeWithChild - Every node accept the final accept state has a child +/// that is executed after the node runs. This class captures this commonality. +class MatcherNodeWithChild : public MatcherNode { + OwningPtr Child; +public: + MatcherNodeWithChild(KindTy K) : MatcherNode(K) {} + + MatcherNode *getChild() { return Child.get(); } + const MatcherNode *getChild() const { return Child.get(); } + void setChild(MatcherNode *C) { Child.reset(C); } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() != EmitNode; + } + +protected: + void printChild(raw_ostream &OS, unsigned indent) const; +}; + +/// PushMatcherNode - This pushes a failure scope on the stack and evaluates +/// 'child'. If 'child' fails to match, it pops its scope and attempts to +/// match 'Failure'. +class PushMatcherNode : public MatcherNodeWithChild { + OwningPtr Failure; +public: + PushMatcherNode(MatcherNode *child = 0, MatcherNode *failure = 0) + : MatcherNodeWithChild(Push), Failure(failure) { + setChild(child); + } + + MatcherNode *getFailure() { return Failure.get(); } + const MatcherNode *getFailure() const { return Failure.get(); } + void setFailure(MatcherNode *N) { Failure.reset(N); } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == Push; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// RecordMatcherNode - Save the current node in the operand list. +class RecordMatcherNode : public MatcherNodeWithChild { +public: + RecordMatcherNode() : MatcherNodeWithChild(Record) {} + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == Record; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// MoveChildMatcherNode - This tells the interpreter to move into the +/// specified child node. +class MoveChildMatcherNode : public MatcherNodeWithChild { + unsigned ChildNo; +public: + MoveChildMatcherNode(unsigned childNo) + : MatcherNodeWithChild(MoveChild), ChildNo(childNo) {} + + unsigned getChildNo() const { return ChildNo; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == MoveChild; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// MoveParentMatcherNode - This tells the interpreter to move to the parent +/// of the current node. +class MoveParentMatcherNode : public MatcherNodeWithChild { +public: + MoveParentMatcherNode() + : MatcherNodeWithChild(MoveParent) {} + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == MoveParent; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckSameMatcherNode - This checks to see if this node is exactly the same +/// node as the specified match that was recorded with 'Record'. This is used +/// when patterns have the same name in them, like '(mul GPR:$in, GPR:$in)'. +class CheckSameMatcherNode : public MatcherNodeWithChild { + unsigned MatchNumber; +public: + CheckSameMatcherNode(unsigned matchnumber) + : MatcherNodeWithChild(CheckSame), MatchNumber(matchnumber) {} + + unsigned getMatchNumber() const { return MatchNumber; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckSame; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckPatternPredicateMatcherNode - This checks the target-specific predicate +/// to see if the entire pattern is capable of matching. This predicate does +/// not take a node as input. This is used for subtarget feature checks etc. +class CheckPatternPredicateMatcherNode : public MatcherNodeWithChild { + std::string Predicate; +public: + CheckPatternPredicateMatcherNode(StringRef predicate) + : MatcherNodeWithChild(CheckPatternPredicate), Predicate(predicate) {} + + StringRef getPredicate() const { return Predicate; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckPatternPredicate; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckPredicateMatcherNode - This checks the target-specific predicate to +/// see if the node is acceptable. +class CheckPredicateMatcherNode : public MatcherNodeWithChild { + StringRef PredName; +public: + CheckPredicateMatcherNode(StringRef predname) + : MatcherNodeWithChild(CheckPredicate), PredName(predname) {} + + StringRef getPredicateName() const { return PredName; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckPredicate; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + + +/// CheckOpcodeMatcherNode - This checks to see if the current node has the +/// specified opcode, if not it fails to match. +class CheckOpcodeMatcherNode : public MatcherNodeWithChild { + StringRef OpcodeName; +public: + CheckOpcodeMatcherNode(StringRef opcodename) + : MatcherNodeWithChild(CheckOpcode), OpcodeName(opcodename) {} + + StringRef getOpcodeName() const { return OpcodeName; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckOpcode; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckTypeMatcherNode - This checks to see if the current node has the +/// specified type, if not it fails to match. +class CheckTypeMatcherNode : public MatcherNodeWithChild { + MVT::SimpleValueType Type; +public: + CheckTypeMatcherNode(MVT::SimpleValueType type) + : MatcherNodeWithChild(CheckType), Type(type) {} + + MVT::SimpleValueType getType() const { return Type; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckType; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckIntegerMatcherNode - This checks to see if the current node is a +/// ConstantSDNode with the specified integer value, if not it fails to match. +class CheckIntegerMatcherNode : public MatcherNodeWithChild { + int64_t Value; +public: + CheckIntegerMatcherNode(int64_t value) + : MatcherNodeWithChild(CheckInteger), Value(value) {} + + int64_t getValue() const { return Value; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckInteger; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckCondCodeMatcherNode - This checks to see if the current node is a +/// CondCodeSDNode with the specified condition, if not it fails to match. +class CheckCondCodeMatcherNode : public MatcherNodeWithChild { + StringRef CondCodeName; +public: + CheckCondCodeMatcherNode(StringRef condcodename) + : MatcherNodeWithChild(CheckCondCode), CondCodeName(condcodename) {} + + StringRef getCondCodeName() const { return CondCodeName; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckCondCode; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckValueTypeMatcherNode - This checks to see if the current node is a +/// VTSDNode with the specified type, if not it fails to match. +class CheckValueTypeMatcherNode : public MatcherNodeWithChild { + StringRef TypeName; +public: + CheckValueTypeMatcherNode(StringRef type_name) + : MatcherNodeWithChild(CheckValueType), TypeName(type_name) {} + + StringRef getTypeName() const { return TypeName; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckValueType; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + + + +/// CheckComplexPatMatcherNode - This node runs the specified ComplexPattern on +/// the current node. +class CheckComplexPatMatcherNode : public MatcherNodeWithChild { + const ComplexPattern &Pattern; +public: + CheckComplexPatMatcherNode(const ComplexPattern &pattern) + : MatcherNodeWithChild(CheckComplexPat), Pattern(pattern) {} + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckComplexPat; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckAndImmMatcherNode - This checks to see if the current node is an 'and' +/// with something equivalent to the specified immediate. +class CheckAndImmMatcherNode : public MatcherNodeWithChild { + int64_t Value; +public: + CheckAndImmMatcherNode(int64_t value) + : MatcherNodeWithChild(CheckAndImm), Value(value) {} + + int64_t getValue() const { return Value; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckAndImm; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckOrImmMatcherNode - This checks to see if the current node is an 'and' +/// with something equivalent to the specified immediate. +class CheckOrImmMatcherNode : public MatcherNodeWithChild { + int64_t Value; +public: + CheckOrImmMatcherNode(int64_t value) + : MatcherNodeWithChild(CheckOrImm), Value(value) {} + + int64_t getValue() const { return Value; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckOrImm; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + + +} // end namespace llvm + +#endif Added: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96215&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (added) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Mon Feb 15 02:04:42 2010 @@ -0,0 +1,217 @@ +//===- DAGISelMatcherEmitter.cpp - Matcher Emitter ------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains code to generate C++ code a matcher. +// +//===----------------------------------------------------------------------===// + +#include "DAGISelMatcher.h" +#include "CodeGenDAGPatterns.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/FormattedStream.h" +using namespace llvm; + +namespace { +enum { + CommentIndent = 25 +}; +} + +static unsigned EmitMatcherAndChildren(const MatcherNode *N, + formatted_raw_ostream &FOS, + unsigned Indent); + +/// ClassifyInt - Classify an integer by size, return '1','2','4','8' if this +/// fits in 1, 2, 4, or 8 sign extended bytes. +static char ClassifyInt(int64_t Val) { + if (Val == int8_t(Val)) return '1'; + if (Val == int16_t(Val)) return '2'; + if (Val == int32_t(Val)) return '4'; + return '8'; +} + +/// EmitInt - Emit the specified integer, returning the number of bytes emitted. +static unsigned EmitInt(int64_t Val, formatted_raw_ostream &OS) { + unsigned BytesEmitted = 1; + OS << (int)(unsigned char)Val << ", "; + if (Val == int8_t(Val)) { + OS << "\n"; + return BytesEmitted; + } + + OS << (int)(unsigned char)(Val >> 8) << ", "; + ++BytesEmitted; + + if (Val != int16_t(Val)) { + OS << (int)(unsigned char)(Val >> 16) << ',' + << (int)(unsigned char)(Val >> 24) << ','; + BytesEmitted += 2; + + if (Val != int32_t(Val)) { + OS << (int)(unsigned char)(Val >> 32) << ',' + << (int)(unsigned char)(Val >> 40) << ',' + << (int)(unsigned char)(Val >> 48) << ',' + << (int)(unsigned char)(Val >> 56) << ','; + BytesEmitted += 4; + } + } + + OS.PadToColumn(CommentIndent) << "// " << Val << '\n'; + return BytesEmitted; +} + +/// EmitMatcherOpcodes - Emit bytes for the specified matcher and return +/// the number of bytes emitted. +static unsigned EmitMatcher(const MatcherNode *N, formatted_raw_ostream &OS, + unsigned Indent) { + OS.PadToColumn(Indent*2); + + switch (N->getKind()) { + case MatcherNode::Push: assert(0 && "Should be handled by caller"); + case MatcherNode::EmitNode: + OS << "OPC_Emit, /*XXX*/"; + OS.PadToColumn(CommentIndent) << "// Src: " + << *cast(N)->getPattern().getSrcPattern() << '\n'; + OS.PadToColumn(CommentIndent) << "// Dst: " + << *cast(N)->getPattern().getDstPattern() << '\n'; + return 1; + case MatcherNode::Record: + OS << "OPC_Record,\n"; + return 1; + case MatcherNode::MoveChild: + OS << "OPC_MoveChild, " + << cast(N)->getChildNo() << ",\n"; + return 2; + + case MatcherNode::MoveParent: + OS << "OPC_MoveParent,\n"; + return 1; + + case MatcherNode::CheckSame: + OS << "OPC_CheckSame, " + << cast(N)->getMatchNumber() << ",\n"; + return 2; + + case MatcherNode::CheckPatternPredicate: + OS << "OPC_CheckPatternPredicate, /*XXX*/0,"; + OS.PadToColumn(CommentIndent) << "// " + << cast(N)->getPredicate() << '\n'; + return 2; + + case MatcherNode::CheckPredicate: + OS << "OPC_CheckPredicate, /*XXX*/0,"; + OS.PadToColumn(CommentIndent) << "// " + << cast(N)->getPredicateName() << '\n'; + return 2; + + case MatcherNode::CheckOpcode: + OS << "OPC_CheckOpcode, " + << cast(N)->getOpcodeName() << ",\n"; + return 2; + + case MatcherNode::CheckType: + OS << "OPC_CheckType, " + << getEnumName(cast(N)->getType()) << ",\n"; + return 2; + + case MatcherNode::CheckInteger: { + int64_t Val = cast(N)->getValue(); + OS << "OPC_CheckInteger" << ClassifyInt(Val) << ", "; + return EmitInt(Val, OS)+1; + } + case MatcherNode::CheckCondCode: + OS << "OPC_CheckCondCode, ISD::" + << cast(N)->getCondCodeName() << ",\n"; + return 2; + + case MatcherNode::CheckValueType: + OS << "OPC_CheckValueType, MVT::" + << cast(N)->getTypeName() << ",\n"; + return 2; + + case MatcherNode::CheckComplexPat: + OS << "OPC_CheckComplexPat, 0/*XXX*/,\n"; + return 2; + + case MatcherNode::CheckAndImm: { + int64_t Val = cast(N)->getValue(); + OS << "OPC_CheckAndImm" << ClassifyInt(Val) << ", "; + return EmitInt(Val, OS)+1; + } + + case MatcherNode::CheckOrImm: { + int64_t Val = cast(N)->getValue(); + OS << "OPC_CheckOrImm" << ClassifyInt(Val) << ", "; + return EmitInt(Val, OS)+1; + } + } + assert(0 && "Unreachable"); + return 0; +} + +/// EmitMatcherAndChildren - Emit the bytes for the specified matcher subtree. +static unsigned EmitMatcherAndChildren(const MatcherNode *N, + formatted_raw_ostream &OS, + unsigned Indent) { + unsigned Size = 0; + while (1) { + // Push is a special case since it is binary. + if (const PushMatcherNode *PMN = dyn_cast(N)) { + // We need to encode the child and the offset of the failure code before + // emitting either of them. Handle this by buffering the output into a + // string while we get the size. + SmallString<128> TmpBuf; + unsigned ChildSize; + { + raw_svector_ostream OS(TmpBuf); + formatted_raw_ostream FOS(OS); + ChildSize = + EmitMatcherAndChildren(cast(N)->getChild(), FOS, + Indent+1); + } + + if (ChildSize > 255) { + errs() << + "Tblgen internal error: can't handle predicate this complex yet\n"; + exit(1); + } + + OS.PadToColumn(Indent*2); + OS << "OPC_Push, " << ChildSize << ",\n"; + OS << TmpBuf.str(); + + Size += 2 + ChildSize; + + N = PMN->getFailure(); + continue; + } + + Size += EmitMatcher(N, OS, Indent); + + // If there are children of this node, iterate to them, otherwise we're + // done. + if (const MatcherNodeWithChild *MNWC = dyn_cast(N)) + N = MNWC->getChild(); + else + return Size; + } +} + +void llvm::EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &O) { + formatted_raw_ostream OS(O); + + OS << "// The main instruction selector code.\n"; + OS << "SDNode *SelectCode2(SDNode *N) {\n"; + + OS << " static const unsigned char MatcherTable[] = {\n"; + unsigned TotalSize = EmitMatcherAndChildren(Matcher, OS, 2); + OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; + OS << " return SelectCodeCommon(N, MatcherTable, sizeof(MatcherTable));\n}\n"; +} Added: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96215&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (added) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Mon Feb 15 02:04:42 2010 @@ -0,0 +1,287 @@ +//===- DAGISelMatcherGen.cpp - Matcher generator --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "DAGISelMatcher.h" +#include "CodeGenDAGPatterns.h" +#include "Record.h" +#include "llvm/ADT/StringMap.h" +using namespace llvm; + +namespace { + class MatcherGen { + const PatternToMatch &Pattern; + const CodeGenDAGPatterns &CGP; + + /// PatWithNoTypes - This is a clone of Pattern.getSrcPattern() that starts + /// out with all of the types removed. This allows us to insert type checks + /// as we scan the tree. + TreePatternNode *PatWithNoTypes; + + /// VariableMap - A map from variable names ('$dst') to the recorded operand + /// number that they were captured as. These are biased by 1 to make + /// insertion easier. + StringMap VariableMap; + unsigned NextRecordedOperandNo; + + MatcherNodeWithChild *Matcher; + MatcherNodeWithChild *CurPredicate; + public: + MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp); + + ~MatcherGen() { + delete PatWithNoTypes; + } + + void EmitMatcherCode(); + + MatcherNodeWithChild *GetMatcher() const { return Matcher; } + MatcherNodeWithChild *GetCurPredicate() const { return CurPredicate; } + private: + void AddMatcherNode(MatcherNodeWithChild *NewNode); + void InferPossibleTypes(); + void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes); + void EmitLeafMatchCode(const TreePatternNode *N); + void EmitOperatorMatchCode(const TreePatternNode *N, + TreePatternNode *NodeNoTypes); + }; + +} // end anon namespace. + +MatcherGen::MatcherGen(const PatternToMatch &pattern, + const CodeGenDAGPatterns &cgp) +: Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), + Matcher(0), CurPredicate(0) { + // We need to produce the matcher tree for the patterns source pattern. To do + // this we need to match the structure as well as the types. To do the type + // matching, we want to figure out the fewest number of type checks we need to + // emit. For example, if there is only one integer type supported by a + // target, there should be no type comparisons at all for integer patterns! + // + // To figure out the fewest number of type checks needed, clone the pattern, + // remove the types, then perform type inference on the pattern as a whole. + // If there are unresolved types, emit an explicit check for those types, + // apply the type to the tree, then rerun type inference. Iterate until all + // types are resolved. + // + PatWithNoTypes = Pattern.getSrcPattern()->clone(); + PatWithNoTypes->RemoveAllTypes(); + + // If there are types that are manifestly known, infer them. + InferPossibleTypes(); +} + +/// InferPossibleTypes - As we emit the pattern, we end up generating type +/// checks and applying them to the 'PatWithNoTypes' tree. As we do this, we +/// want to propagate implied types as far throughout the tree as possible so +/// that we avoid doing redundant type checks. This does the type propagation. +void MatcherGen::InferPossibleTypes() { + // TP - Get *SOME* tree pattern, we don't care which. It is only used for + // diagnostics, which we know are impossible at this point. + TreePattern &TP = *CGP.pf_begin()->second; + + try { + bool MadeChange = true; + while (MadeChange) + MadeChange = PatWithNoTypes->ApplyTypeConstraints(TP, + true/*Ignore reg constraints*/); + } catch (...) { + errs() << "Type constraint application shouldn't fail!"; + abort(); + } +} + + +/// AddMatcherNode - Add a matcher node to the current graph we're building. +void MatcherGen::AddMatcherNode(MatcherNodeWithChild *NewNode) { + if (CurPredicate != 0) + CurPredicate->setChild(NewNode); + else + Matcher = NewNode; + CurPredicate = NewNode; +} + + + +/// EmitLeafMatchCode - Generate matching code for leaf nodes. +void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) { + assert(N->isLeaf() && "Not a leaf?"); + // Direct match against an integer constant. + if (IntInit *II = dynamic_cast(N->getLeafValue())) + return AddMatcherNode(new CheckIntegerMatcherNode(II->getValue())); + + DefInit *DI = dynamic_cast(N->getLeafValue()); + if (DI == 0) { + errs() << "Unknown leaf kind: " << *DI << "\n"; + abort(); + } + + Record *LeafRec = DI->getDef(); + if (// Handle register references. Nothing to do here, they always match. + LeafRec->isSubClassOf("RegisterClass") || + LeafRec->isSubClassOf("PointerLikeRegClass") || + LeafRec->isSubClassOf("Register") || + // Place holder for SRCVALUE nodes. Nothing to do here. + LeafRec->getName() == "srcvalue") + return; + + if (LeafRec->isSubClassOf("ValueType")) + return AddMatcherNode(new CheckValueTypeMatcherNode(LeafRec->getName())); + + if (LeafRec->isSubClassOf("CondCode")) + return AddMatcherNode(new CheckCondCodeMatcherNode(LeafRec->getName())); + + if (LeafRec->isSubClassOf("ComplexPattern")) { + // Handle complex pattern. + const ComplexPattern &CP = CGP.getComplexPattern(LeafRec); + return AddMatcherNode(new CheckComplexPatMatcherNode(CP)); + } + + errs() << "Unknown leaf kind: " << *N << "\n"; + abort(); +} + +void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N, + TreePatternNode *NodeNoTypes) { + assert(!N->isLeaf() && "Not an operator?"); + const SDNodeInfo &CInfo = CGP.getSDNodeInfo(N->getOperator()); + + // If this is an 'and R, 1234' where the operation is AND/OR and the RHS is + // a constant without a predicate fn that has more that one bit set, handle + // this as a special case. This is usually for targets that have special + // handling of certain large constants (e.g. alpha with it's 8/16/32-bit + // handling stuff). Using these instructions is often far more efficient + // than materializing the constant. Unfortunately, both the instcombiner + // and the dag combiner can often infer that bits are dead, and thus drop + // them from the mask in the dag. For example, it might turn 'AND X, 255' + // into 'AND X, 254' if it knows the low bit is set. Emit code that checks + // to handle this. + if ((N->getOperator()->getName() == "and" || + N->getOperator()->getName() == "or") && + N->getChild(1)->isLeaf() && N->getChild(1)->getPredicateFns().empty()) { + if (IntInit *II = dynamic_cast(N->getChild(1)->getLeafValue())) { + if (!isPowerOf2_32(II->getValue())) { // Don't bother with single bits. + if (N->getOperator()->getName() == "and") + AddMatcherNode(new CheckAndImmMatcherNode(II->getValue())); + else + AddMatcherNode(new CheckOrImmMatcherNode(II->getValue())); + + // Match the LHS of the AND as appropriate. + AddMatcherNode(new MoveChildMatcherNode(0)); + EmitMatchCode(N->getChild(0), NodeNoTypes->getChild(0)); + AddMatcherNode(new MoveParentMatcherNode()); + return; + } + } + } + + // Check that the current opcode lines up. + AddMatcherNode(new CheckOpcodeMatcherNode(CInfo.getEnumName())); + + // If this node has a chain, then the chain is operand #0 is the SDNode, and + // the child numbers of the node are all offset by one. + unsigned OpNo = 0; + if (N->NodeHasProperty(SDNPHasChain, CGP)) + OpNo = 1; + + if (N->TreeHasProperty(SDNPHasChain, CGP)) { + // FIXME: Handle Chains with multiple uses etc. + // [ld] + // ^ ^ + // | | + // / \--- + // / [YY] + // | ^ + // [XX]-------| + } + + // FIXME: Handle Flags & .hasOneUse() + + for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { + // Get the code suitable for matching this child. Move to the child, check + // it then move back to the parent. + AddMatcherNode(new MoveChildMatcherNode(i)); + EmitMatchCode(N->getChild(i), NodeNoTypes->getChild(i)); + AddMatcherNode(new MoveParentMatcherNode()); + } +} + + +void MatcherGen::EmitMatchCode(const TreePatternNode *N, + TreePatternNode *NodeNoTypes) { + // If N and NodeNoTypes don't agree on a type, then this is a case where we + // need to do a type check. Emit the check, apply the tyep to NodeNoTypes and + // reinfer any correlated types. + if (NodeNoTypes->getExtTypes() != N->getExtTypes()) { + AddMatcherNode(new CheckTypeMatcherNode(N->getTypeNum(0))); + NodeNoTypes->setTypes(N->getExtTypes()); + InferPossibleTypes(); + } + + + // If this node has a name associated with it, capture it in VariableMap. If + // we already saw this in the pattern, emit code to verify dagness. + if (!N->getName().empty()) { + unsigned &VarMapEntry = VariableMap[N->getName()]; + if (VarMapEntry == 0) { + VarMapEntry = ++NextRecordedOperandNo; + AddMatcherNode(new RecordMatcherNode()); + } else { + // If we get here, this is a second reference to a specific name. Since + // we already have checked that the first reference is valid, we don't + // have to recursively match it, just check that it's the same as the + // previously named thing. + AddMatcherNode(new CheckSameMatcherNode(VarMapEntry-1)); + return; + } + } + + // If there are node predicates for this node, generate their checks. + for (unsigned i = 0, e = N->getPredicateFns().size(); i != e; ++i) + AddMatcherNode(new CheckPredicateMatcherNode(N->getPredicateFns()[i])); + + if (N->isLeaf()) + EmitLeafMatchCode(N); + else + EmitOperatorMatchCode(N, NodeNoTypes); +} + +void MatcherGen::EmitMatcherCode() { + // If the pattern has a predicate on it (e.g. only enabled when a subtarget + // feature is around, do the check). + if (!Pattern.getPredicateCheck().empty()) + AddMatcherNode(new + CheckPatternPredicateMatcherNode(Pattern.getPredicateCheck())); + + // Emit the matcher for the pattern structure and types. + EmitMatchCode(Pattern.getSrcPattern(), PatWithNoTypes); +} + + +MatcherNode *llvm::ConvertPatternToMatcher(const PatternToMatch &Pattern, + const CodeGenDAGPatterns &CGP) { + MatcherGen Gen(Pattern, CGP); + + // Generate the code for the matcher. + Gen.EmitMatcherCode(); + + // If the match succeeds, then we generate Pattern. + EmitNodeMatcherNode *Result = new EmitNodeMatcherNode(Pattern); + + // Link it into the pattern. + if (MatcherNodeWithChild *Pred = Gen.GetCurPredicate()) { + Pred->setChild(Result); + return Gen.GetMatcher(); + } + + // Unconditional match. + return Result; +} + + + From gohman at apple.com Mon Feb 15 04:28:39 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Feb 2010 10:28:39 -0000 Subject: [llvm-commits] [llvm] r96216 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <201002151028.o1FASdjp020435@zion.cs.uiuc.edu> Author: djg Date: Mon Feb 15 04:28:37 2010 New Revision: 96216 URL: http://llvm.org/viewvc/llvm-project?rev=96216&view=rev Log: When testing whether a given SCEV depends on a temporary symbolic name, test whether the SCEV itself is that temporary symbolic name, in addition to checking whether the symbolic name appears as a possibly-indirect operand. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96216&r1=96215&r2=96216&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Feb 15 04:28:37 2010 @@ -2566,7 +2566,7 @@ if (It != Scalars.end()) { // Short-circuit the def-use traversal if the symbolic name // ceases to appear in expressions. - if (!It->second->hasOperand(SymName)) + if (It->second != SymName && !It->second->hasOperand(SymName)) continue; // SCEVUnknown for a PHI either means that it has an unrecognized From baldrick at free.fr Mon Feb 15 08:20:08 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Feb 2010 14:20:08 -0000 Subject: [llvm-commits] [dragonegg] r96218 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <201002151420.o1FEK8rJ031074@zion.cs.uiuc.edu> Author: baldrick Date: Mon Feb 15 08:20:04 2010 New Revision: 96218 URL: http://llvm.org/viewvc/llvm-project?rev=96218&view=rev Log: If the fixed adjustment justs adds zero, then skip it. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=96218&r1=96217&r2=96218&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Mon Feb 15 08:20:04 2010 @@ -1652,12 +1652,15 @@ FoundThis = true; // The current argument is 'this'. assert(isa(AI->getType()) && "Wrong type for 'this'!"); + Value *This = AI; // Adjust 'this' according to the thunk offsets. First, the fixed offset. - Value *This = Builder.CreatePtrToInt(AI, IntPtrTy); - Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset); - This = Builder.CreateNSWAdd(This, Offset); - This = Builder.CreateIntToPtr(This, AI->getType()); + if (node->thunk.fixed_offset) { + This = Builder.CreatePtrToInt(This, IntPtrTy); + Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset); + This = Builder.CreateNSWAdd(This, Offset); + This = Builder.CreateIntToPtr(This, AI->getType()); + } // Then by the virtual offset, if any. if (node->thunk.virtual_offset_p) @@ -1704,10 +1707,12 @@ RetVal = ApplyVirtualOffset(RetVal, node->thunk.virtual_value, Builder); // Then move 'this' by the fixed offset. - RetVal = Builder.CreatePtrToInt(RetVal, IntPtrTy); - Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset); - RetVal = Builder.CreateNSWAdd(RetVal, Offset); - RetVal = Builder.CreateIntToPtr(RetVal, Thunk->getType()); + if (node->thunk.fixed_offset) { + RetVal = Builder.CreatePtrToInt(RetVal, IntPtrTy); + Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset); + RetVal = Builder.CreateNSWAdd(RetVal, Offset); + RetVal = Builder.CreateIntToPtr(RetVal, Thunk->getType()); + } // Return the adjusted value. Builder.CreateRet(RetVal); From baldrick at free.fr Mon Feb 15 08:32:14 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Feb 2010 14:32:14 -0000 Subject: [llvm-commits] [dragonegg] r96219 - /dragonegg/trunk/bits_and_bobs.cpp Message-ID: <201002151432.o1FEWEMI031644@zion.cs.uiuc.edu> Author: baldrick Date: Mon Feb 15 08:32:14 2010 New Revision: 96219 URL: http://llvm.org/viewvc/llvm-project?rev=96219&view=rev Log: Do not include a bunch of unused headers. Added: dragonegg/trunk/bits_and_bobs.cpp Added: dragonegg/trunk/bits_and_bobs.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/bits_and_bobs.cpp?rev=96219&view=auto ============================================================================== --- dragonegg/trunk/bits_and_bobs.cpp (added) +++ dragonegg/trunk/bits_and_bobs.cpp Mon Feb 15 08:32:14 2010 @@ -0,0 +1,11 @@ +#include + +bool flag_odr = false; + +int ix86_regparm; + +union tree_node; + +extern "C" bool contains_aligned_value_p (union tree_node *type) { + abort(); +} From alenhar2 at cs.uiuc.edu Mon Feb 15 09:00:44 2010 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 15 Feb 2010 15:00:44 -0000 Subject: [llvm-commits] [llvm] r96220 - /llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <201002151500.o1FF0i6C000583@zion.cs.uiuc.edu> Author: alenhar2 Date: Mon Feb 15 09:00:44 2010 New Revision: 96220 URL: http://llvm.org/viewvc/llvm-project?rev=96220&view=rev Log: Fix changes from r75027 Modified: llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp Modified: llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp?rev=96220&r1=96219&r2=96220&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaRegisterInfo.cpp Mon Feb 15 09:00:44 2010 @@ -251,7 +251,7 @@ } else { std::string msg; raw_string_ostream Msg(msg); - Msg << "Too big a stack frame at " + NumBytes; + Msg << "Too big a stack frame at " << NumBytes; llvm_report_error(Msg.str()); } @@ -303,15 +303,14 @@ } else { std::string msg; raw_string_ostream Msg(msg); - Msg << "Too big a stack frame at " + NumBytes; + Msg << "Too big a stack frame at " << NumBytes; llvm_report_error(Msg.str()); } } } unsigned AlphaRegisterInfo::getRARegister() const { - llvm_unreachable("What is the return address register"); - return 0; + return Alpha::R26; } unsigned AlphaRegisterInfo::getFrameRegister(const MachineFunction &MF) const { From ofv at wanadoo.es Mon Feb 15 09:17:05 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 15 Feb 2010 15:17:05 -0000 Subject: [llvm-commits] [llvm] r96221 - /llvm/trunk/projects/CMakeLists.txt Message-ID: <201002151517.o1FFH6xl001335@zion.cs.uiuc.edu> Author: ofv Date: Mon Feb 15 09:17:05 2010 New Revision: 96221 URL: http://llvm.org/viewvc/llvm-project?rev=96221&view=rev Log: CMake: Fixed syntax in conditional. Modified: llvm/trunk/projects/CMakeLists.txt Modified: llvm/trunk/projects/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/projects/CMakeLists.txt?rev=96221&r1=96220&r2=96221&view=diff ============================================================================== --- llvm/trunk/projects/CMakeLists.txt (original) +++ llvm/trunk/projects/CMakeLists.txt Mon Feb 15 09:17:05 2010 @@ -4,7 +4,7 @@ file(GLOB entries *) foreach(entry ${entries}) if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt) - if(NOT (${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt)) + if(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt) add_subdirectory(${entry}) endif() endif() From rafael.espindola at gmail.com Mon Feb 15 09:41:19 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 15 Feb 2010 15:41:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96222 - /llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp Message-ID: <201002151541.o1FFfJnP002657@zion.cs.uiuc.edu> Author: rafael Date: Mon Feb 15 09:41:17 2010 New Revision: 96222 URL: http://llvm.org/viewvc/llvm-project?rev=96222&view=rev Log: Move all ppc linux specific logic to llvm_ppc_try_pass_aggregate_custom. With this patch the only difference between the default and the ppc linux implementations is the call to llvm_ppc_try_pass_aggregate_custom. Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp?rev=96222&r1=96221&r2=96222&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp Mon Feb 15 09:41:17 2010 @@ -83,52 +83,31 @@ return NumGPRs < 8 ? NumGPRs : 8; } -/// HandleArgument - This is invoked by the target-independent code for each -/// argument type passed into the function. It potentially breaks down the -/// argument and invokes methods on the client that indicate how its pieces -/// should be handled. This handles things like decimating structures into -/// their fields. -/// +static bool isSVR4ABI() { +#if defined(POWERPC_LINUX) && (TARGET_64BIT == 0) + return true; +#else + return false; +#endif +} + /// _Complex arguments are never split, thus their two scalars are either /// passed both in argument registers or both on the stack. Also _Complex /// arguments are always passed in general purpose registers, never in /// Floating-point registers or vector registers. -void SVR4ABI::HandleArgument(tree type, std::vector &ScalarElts, - Attributes *Attributes) { - unsigned Size = 0; - bool DontCheckAlignment = false; +static bool +llvm_ppc_try_pass_aggregate_custom(tree type, std::vector &ScalarElts, + const CallingConv::ID &CC, + struct DefaultABIClient* C) { + if (!isSVR4ABI()) + return false; + // Eight GPR's are availabe for parameter passing. const unsigned NumArgRegs = 8; unsigned NumGPR = count_num_registers_uses(ScalarElts); const Type *Ty = ConvertType(type); - // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do - // not include variable sized fields here. - std::vector Elts; const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); - if (Ty->isVoidTy()) { - // Handle void explicitly as an opaque type. - const Type *OpTy = OpaqueType::get(getGlobalContext()); - C.HandleScalarArgument(OpTy, type); - ScalarElts.push_back(OpTy); - } else if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - const Type *PtrTy = Ty->getPointerTo(); - C.HandleByInvisibleReferenceArgument(PtrTy, type); - ScalarElts.push_back(PtrTy); - } else if (isa(Ty)) { - if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) { - PassInIntegerRegisters(type, ScalarElts, 0, false); - } else if (LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(type)) { - C.HandleByValArgument(Ty, type); - if (Attributes) { - *Attributes |= Attribute::ByVal; - *Attributes |= - Attribute::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); - } - } else { - C.HandleScalarArgument(Ty, type); - ScalarElts.push_back(Ty); - } - } else if (Ty->isSingleValueType()) { + if (Ty->isSingleValueType()) { if (Ty->isInteger()) { unsigned TypeSize = Ty->getPrimitiveSizeInBits(); @@ -141,13 +120,13 @@ if (TypeSize == 64 && (NumGPR % 2) == 1) { NumGPR++; ScalarElts.push_back(Int32Ty); - C.HandlePad(Int32Ty); + C->HandlePad(Int32Ty); } if (NumGPR > (NumArgRegs - NumRegs)) { for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { ScalarElts.push_back(Int32Ty); - C.HandlePad(Int32Ty); + C->HandlePad(Int32Ty); } } } else if (!(Ty->isFloatingPoint() || @@ -156,70 +135,105 @@ abort(); } - C.HandleScalarArgument(Ty, type); + C->HandleScalarArgument(Ty, type); ScalarElts.push_back(Ty); - } else if (LLVM_SHOULD_PASS_AGGREGATE_AS_FCA(type, Ty)) { - C.HandleFCAArgument(Ty, type); - } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, - C.getCallingConv(), - Elts)) { - HOST_WIDE_INT SrcSize = int_size_in_bytes(type); - - // With the SVR4 ABI, the only aggregates which are passed in registers - // are _Complex aggregates. - assert(TREE_CODE(type) == COMPLEX_TYPE && "Not a _Complex type!"); - - switch (SrcSize) { - default: - abort(); - break; - case 32: - // _Complex long double - if (NumGPR != 0) { - for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { - ScalarElts.push_back(Int32Ty); - C.HandlePad(Int32Ty); - } - } - break; - case 16: - // _Complex long long - // _Complex double - if (NumGPR > (NumArgRegs - 4)) { - for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { - ScalarElts.push_back(Int32Ty); - C.HandlePad(Int32Ty); - } - } - break; - case 8: - // _Complex int - // _Complex long - // _Complex float + return true; + } + if (TREE_CODE(type) == COMPLEX_TYPE) { + unsigned SrcSize = int_size_in_bytes(type); + unsigned NumRegs = (SrcSize + 3) / 4; + std::vector Elts; + // This looks very strange, but matches the old code. + if (SrcSize == 8) { // Make sure argument registers are aligned. 64-bit arguments are put in // a register pair which starts with an odd register number. if (NumGPR % 2 == 1) { NumGPR++; ScalarElts.push_back(Int32Ty); - C.HandlePad(Int32Ty); + C->HandlePad(Int32Ty); } + } - if (NumGPR > (NumArgRegs - 2)) { - for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { - ScalarElts.push_back(Int32Ty); - C.HandlePad(Int32Ty); - } + if (NumGPR > (NumArgRegs - NumRegs)) { + for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { + ScalarElts.push_back(Int32Ty); + C->HandlePad(Int32Ty); } - break; - case 4: - case 2: - // _Complex short - // _Complex char - break; } + for (unsigned int i = 0; i < NumRegs; ++i) { + Elts.push_back(Int32Ty); + } + const StructType *STy = StructType::get(getGlobalContext(), Elts, false); + for (unsigned int i = 0; i < NumRegs; ++i) { + C->EnterField(i, STy); + C->HandleScalarArgument(Int32Ty, 0); + ScalarElts.push_back(Int32Ty); + C->ExitField(); + } + return true; + } + return false; +} - PassInMixedRegisters(Ty, Elts, ScalarElts); +/// HandleArgument - This is invoked by the target-independent code for each +/// argument type passed into the function. It potentially breaks down the +/// argument and invokes methods on the client that indicate how its pieces +/// should be handled. This handles things like decimating structures into +/// their fields. +void SVR4ABI::HandleArgument(tree type, std::vector &ScalarElts, + Attributes *Attributes) { + unsigned Size = 0; + bool DontCheckAlignment = false; + const Type *Ty = ConvertType(type); + // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do + // not include variable sized fields here. + std::vector Elts; + if (Ty->isVoidTy()) { + // Handle void explicitly as an opaque type. + const Type *OpTy = OpaqueType::get(getGlobalContext()); + C.HandleScalarArgument(OpTy, type); + ScalarElts.push_back(OpTy); + } else if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. + const Type *PtrTy = Ty->getPointerTo(); + C.HandleByInvisibleReferenceArgument(PtrTy, type); + ScalarElts.push_back(PtrTy); + } else if (isa(Ty)) { + if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) { + PassInIntegerRegisters(type, ScalarElts, 0, false); + } else if (LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(type)) { + C.HandleByValArgument(Ty, type); + if (Attributes) { + *Attributes |= Attribute::ByVal; + *Attributes |= + Attribute::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); + } + } else { + C.HandleScalarArgument(Ty, type); + ScalarElts.push_back(Ty); + } + } else if (llvm_ppc_try_pass_aggregate_custom(type, ScalarElts, C.getCallingConv(), &C)) { + // Nothing to do. + } else if (Ty->isSingleValueType()) { + C.HandleScalarArgument(Ty, type); + ScalarElts.push_back(Ty); + } else if (LLVM_SHOULD_PASS_AGGREGATE_AS_FCA(type, Ty)) { + C.HandleFCAArgument(Ty, type); + } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, + C.getCallingConv(), + Elts)) { + if (!LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Elts, ScalarElts, + C.isShadowReturn(), + C.getCallingConv())) + PassInMixedRegisters(Ty, Elts, ScalarElts); + else { + C.HandleByValArgument(Ty, type); + if (Attributes) { + *Attributes |= Attribute::ByVal; + *Attributes |= + Attribute::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); + } + } } else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) { C.HandleByValArgument(Ty, type); if (Attributes) { From baldrick at free.fr Mon Feb 15 10:12:20 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Feb 2010 16:12:20 -0000 Subject: [llvm-commits] [llvm] r96223 - in /llvm/trunk: docs/ include/llvm/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/ lib/ExecutionEngine/Interpreter/ lib/ExecutionEngine/JIT/ lib/Target/CBackend/ lib/Target/CppBackend/ lib/Target/MSIL/ lib/Target/MSP430/ lib/Target/X86/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ Message-ID: <201002151612.o1FGCMZ0004270@zion.cs.uiuc.edu> Author: baldrick Date: Mon Feb 15 10:12:20 2010 New Revision: 96223 URL: http://llvm.org/viewvc/llvm-project?rev=96223&view=rev Log: Uniformize the names of type predicates: rather than having isFloatTy and isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! Modified: llvm/trunk/docs/ProgrammersManual.html llvm/trunk/include/llvm/Instructions.h llvm/trunk/include/llvm/Type.h llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/StackProtector.cpp llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp llvm/trunk/lib/Target/MSIL/MSILWriter.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/lib/Target/X86/X86FloatingPointRegKill.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp llvm/trunk/lib/VMCore/Attributes.cpp llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/lib/VMCore/ValueTypes.cpp llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Mon Feb 15 10:12:20 2010 @@ -2999,9 +2999,9 @@
    -
  • bool isInteger() const: Returns true for any integer type.
  • +
  • bool isIntegerTy() const: Returns true for any integer type.
  • -
  • bool isFloatingPoint(): Return true if this is one of the two +
  • bool isFloatingPointTy(): Return true if this is one of the five floating point types.
  • bool isAbstract(): Return true if the type is abstract (contains Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Mon Feb 15 10:12:20 2010 @@ -590,7 +590,7 @@ assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type - assert((getOperand(0)->getType()->isIntOrIntVector() || + assert((getOperand(0)->getType()->isIntOrIntVectorTy() || isa(getOperand(0)->getType())) && "Invalid operand types for ICmp instruction"); } @@ -611,7 +611,7 @@ assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type - assert((getOperand(0)->getType()->isIntOrIntVector() || + assert((getOperand(0)->getType()->isIntOrIntVectorTy() || isa(getOperand(0)->getType())) && "Invalid operand types for ICmp instruction"); } @@ -630,7 +630,7 @@ assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type - assert((getOperand(0)->getType()->isIntOrIntVector() || + assert((getOperand(0)->getType()->isIntOrIntVectorTy() || isa(getOperand(0)->getType())) && "Invalid operand types for ICmp instruction"); } @@ -740,7 +740,7 @@ assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to FCmp instruction are not of the same type!"); // Check that the operands are the right type - assert(getOperand(0)->getType()->isFPOrFPVector() && + assert(getOperand(0)->getType()->isFPOrFPVectorTy() && "Invalid operand types for FCmp instruction"); } @@ -759,7 +759,7 @@ assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to FCmp instruction are not of the same type!"); // Check that the operands are the right type - assert(getOperand(0)->getType()->isFPOrFPVector() && + assert(getOperand(0)->getType()->isFPOrFPVectorTy() && "Invalid operand types for FCmp instruction"); } @@ -776,7 +776,7 @@ assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to FCmp instruction are not of the same type!"); // Check that the operands are the right type - assert(getOperand(0)->getType()->isFPOrFPVector() && + assert(getOperand(0)->getType()->isFPOrFPVectorTy() && "Invalid operand types for FCmp instruction"); } Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Mon Feb 15 10:12:20 2010 @@ -214,46 +214,46 @@ /// getDescription - Return the string representation of the type. std::string getDescription() const; - /// isInteger - True if this is an instance of IntegerType. + /// isIntegerTy - True if this is an instance of IntegerType. /// - bool isInteger() const { return ID == IntegerTyID; } + bool isIntegerTy() const { return ID == IntegerTyID; } - /// isInteger - Return true if this is an IntegerType of the specified width. - bool isInteger(unsigned Bitwidth) const; + /// isIntegerTy - Return true if this is an IntegerType of the given width. + bool isIntegerTy(unsigned Bitwidth) const; - /// isIntOrIntVector - Return true if this is an integer type or a vector of + /// isIntOrIntVectorTy - Return true if this is an integer type or a vector of /// integer types. /// - bool isIntOrIntVector() const; + bool isIntOrIntVectorTy() const; - /// isFloatingPoint - Return true if this is one of the five floating point + /// isFloatingPointTy - Return true if this is one of the five floating point /// types - bool isFloatingPoint() const { return ID == FloatTyID || ID == DoubleTyID || + bool isFloatingPointTy() const { return ID == FloatTyID || ID == DoubleTyID || ID == X86_FP80TyID || ID == FP128TyID || ID == PPC_FP128TyID; } - /// isFPOrFPVector - Return true if this is a FP type or a vector of FP types. + /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP. /// - bool isFPOrFPVector() const; + bool isFPOrFPVectorTy() const; - /// isFunction - True if this is an instance of FunctionType. + /// isFunctionTy - True if this is an instance of FunctionType. /// - bool isFunction() const { return ID == FunctionTyID; } + bool isFunctionTy() const { return ID == FunctionTyID; } - /// isStruct - True if this is an instance of StructType. + /// isStructTy - True if this is an instance of StructType. /// - bool isStruct() const { return ID == StructTyID; } + bool isStructTy() const { return ID == StructTyID; } - /// isArray - True if this is an instance of ArrayType. + /// isArrayTy - True if this is an instance of ArrayType. /// - bool isArray() const { return ID == ArrayTyID; } + bool isArrayTy() const { return ID == ArrayTyID; } - /// isPointer - True if this is an instance of PointerType. + /// isPointerTy - True if this is an instance of PointerType. /// - bool isPointer() const { return ID == PointerTyID; } + bool isPointerTy() const { return ID == PointerTyID; } - /// isVector - True if this is an instance of VectorType. + /// isVectorTy - True if this is an instance of VectorType. /// - bool isVector() const { return ID == VectorTyID; } + bool isVectorTy() const { return ID == VectorTyID; } /// isAbstract - True if the type is either an Opaque type, or is a derived /// type that includes an opaque type somewhere in it. @@ -307,7 +307,7 @@ /// bool isSized() const { // If it's a primitive, it is always sized. - if (ID == IntegerTyID || isFloatingPoint() || ID == PointerTyID) + if (ID == IntegerTyID || isFloatingPointTy() || ID == PointerTyID) return true; // If it is not something that can have a size (e.g. a function or label), // it doesn't have a size. Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Feb 15 10:12:20 2010 @@ -80,7 +80,7 @@ // First thing is first. We only want to think about integer here, so if // we have something in FP form, recast it as integer. - if (DstEltTy->isFloatingPoint()) { + if (DstEltTy->isFloatingPointTy()) { // Fold to an vector of integers with same size as our FP type. unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits(); const Type *DestIVTy = @@ -95,7 +95,7 @@ // Okay, we know the destination is integer, if the input is FP, convert // it to integer first. - if (SrcEltTy->isFloatingPoint()) { + if (SrcEltTy->isFloatingPointTy()) { unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits(); const Type *SrcIVTy = VectorType::get(IntegerType::get(C->getContext(), FPWidth), NumSrcElt); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Feb 15 10:12:20 2010 @@ -214,8 +214,8 @@ SCEVTruncateExpr::SCEVTruncateExpr(const FoldingSetNodeID &ID, const SCEV *op, const Type *ty) : SCEVCastExpr(ID, scTruncate, op, ty) { - assert((Op->getType()->isInteger() || isa(Op->getType())) && - (Ty->isInteger() || isa(Ty)) && + assert((Op->getType()->isIntegerTy() || isa(Op->getType())) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot truncate non-integer value!"); } @@ -226,8 +226,8 @@ SCEVZeroExtendExpr::SCEVZeroExtendExpr(const FoldingSetNodeID &ID, const SCEV *op, const Type *ty) : SCEVCastExpr(ID, scZeroExtend, op, ty) { - assert((Op->getType()->isInteger() || isa(Op->getType())) && - (Ty->isInteger() || isa(Ty)) && + assert((Op->getType()->isIntegerTy() || isa(Op->getType())) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot zero extend non-integer value!"); } @@ -238,8 +238,8 @@ SCEVSignExtendExpr::SCEVSignExtendExpr(const FoldingSetNodeID &ID, const SCEV *op, const Type *ty) : SCEVCastExpr(ID, scSignExtend, op, ty) { - assert((Op->getType()->isInteger() || isa(Op->getType())) && - (Ty->isInteger() || isa(Ty)) && + assert((Op->getType()->isIntegerTy() || isa(Op->getType())) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot sign extend non-integer value!"); } @@ -394,7 +394,7 @@ if (ConstantInt *CI = dyn_cast(CE->getOperand(2))) if (CI->isOne() && STy->getNumElements() == 2 && - STy->getElementType(0)->isInteger(1)) { + STy->getElementType(0)->isIntegerTy(1)) { AllocTy = STy->getElementType(1); return true; } @@ -2308,7 +2308,7 @@ /// has access to target-specific information. bool ScalarEvolution::isSCEVable(const Type *Ty) const { // Integers and pointers are always SCEVable. - return Ty->isInteger() || isa(Ty); + return Ty->isIntegerTy() || isa(Ty); } /// getTypeSizeInBits - Return the size in bits of the specified type, @@ -2321,7 +2321,7 @@ return TD->getTypeSizeInBits(Ty); // Integer types have fixed sizes. - if (Ty->isInteger()) + if (Ty->isIntegerTy()) return Ty->getPrimitiveSizeInBits(); // The only other support type is pointer. Without TargetData, conservatively @@ -2337,7 +2337,7 @@ const Type *ScalarEvolution::getEffectiveSCEVType(const Type *Ty) const { assert(isSCEVable(Ty) && "Type is not SCEVable!"); - if (Ty->isInteger()) + if (Ty->isIntegerTy()) return Ty; // The only other support type is pointer. @@ -2412,8 +2412,8 @@ ScalarEvolution::getTruncateOrZeroExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isInteger() || isa(SrcTy)) && - (Ty->isInteger() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || isa(SrcTy)) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot truncate or zero extend with non-integer arguments!"); if (getTypeSizeInBits(SrcTy) == getTypeSizeInBits(Ty)) return V; // No conversion @@ -2429,8 +2429,8 @@ ScalarEvolution::getTruncateOrSignExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isInteger() || isa(SrcTy)) && - (Ty->isInteger() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || isa(SrcTy)) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot truncate or zero extend with non-integer arguments!"); if (getTypeSizeInBits(SrcTy) == getTypeSizeInBits(Ty)) return V; // No conversion @@ -2445,8 +2445,8 @@ const SCEV * ScalarEvolution::getNoopOrZeroExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isInteger() || isa(SrcTy)) && - (Ty->isInteger() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || isa(SrcTy)) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot noop or zero extend with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) && "getNoopOrZeroExtend cannot truncate!"); @@ -2461,8 +2461,8 @@ const SCEV * ScalarEvolution::getNoopOrSignExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isInteger() || isa(SrcTy)) && - (Ty->isInteger() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || isa(SrcTy)) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot noop or sign extend with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) && "getNoopOrSignExtend cannot truncate!"); @@ -2478,8 +2478,8 @@ const SCEV * ScalarEvolution::getNoopOrAnyExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isInteger() || isa(SrcTy)) && - (Ty->isInteger() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || isa(SrcTy)) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot noop or any extend with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) && "getNoopOrAnyExtend cannot truncate!"); @@ -2493,8 +2493,8 @@ const SCEV * ScalarEvolution::getTruncateOrNoop(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isInteger() || isa(SrcTy)) && - (Ty->isInteger() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || isa(SrcTy)) && + (Ty->isIntegerTy() || isa(Ty)) && "Cannot truncate or noop with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) >= getTypeSizeInBits(Ty) && "getTruncateOrNoop cannot extend!"); @@ -3068,7 +3068,7 @@ if (const SCEVUnknown *U = dyn_cast(S)) { // For a SCEVUnknown, ask ValueTracking. - if (!U->getValue()->getType()->isInteger() && !TD) + if (!U->getValue()->getType()->isIntegerTy() && !TD) return ConservativeResult; unsigned NS = ComputeNumSignBits(U->getValue(), TD); if (NS == 1) @@ -4450,7 +4450,7 @@ -StartC->getValue()->getValue(), *this); } - } else if (AddRec->isQuadratic() && AddRec->getType()->isInteger()) { + } else if (AddRec->isQuadratic() && AddRec->getType()->isIntegerTy()) { // If this is a quadratic (3-term) AddRec {L,+,M,+,N}, find the roots of // the quadratic equation to solve it. std::pair Roots = SolveQuadraticEquation(AddRec, Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Feb 15 10:12:20 2010 @@ -1104,7 +1104,7 @@ Value * SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty) { - assert(Ty->isInteger() && "Can only insert integer induction variables!"); + assert(Ty->isIntegerTy() && "Can only insert integer induction variables!"); const SCEV *H = SE.getAddRecExpr(SE.getIntegerSCEV(0, Ty), SE.getIntegerSCEV(1, Ty), L); BasicBlock *SaveInsertBB = Builder.GetInsertBlock(); Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Feb 15 10:12:20 2010 @@ -49,11 +49,11 @@ assert(V && "No Value?"); assert(Depth <= MaxDepth && "Limit Search Depth"); unsigned BitWidth = Mask.getBitWidth(); - assert((V->getType()->isIntOrIntVector() || isa(V->getType())) && - "Not integer or pointer type!"); + assert((V->getType()->isIntOrIntVectorTy() || isa(V->getType())) + && "Not integer or pointer type!"); assert((!TD || TD->getTypeSizeInBits(V->getType()->getScalarType()) == BitWidth) && - (!V->getType()->isIntOrIntVector() || + (!V->getType()->isIntOrIntVectorTy() || V->getType()->getScalarSizeInBits() == BitWidth) && KnownZero.getBitWidth() == BitWidth && KnownOne.getBitWidth() == BitWidth && @@ -269,7 +269,7 @@ } case Instruction::BitCast: { const Type *SrcTy = I->getOperand(0)->getType(); - if ((SrcTy->isInteger() || isa(SrcTy)) && + if ((SrcTy->isIntegerTy() || isa(SrcTy)) && // TODO: For now, not handling conversions like: // (bitcast i64 %x to <2 x i32>) !isa(I->getType())) { @@ -649,7 +649,7 @@ /// unsigned llvm::ComputeNumSignBits(Value *V, const TargetData *TD, unsigned Depth) { - assert((TD || V->getType()->isIntOrIntVector()) && + assert((TD || V->getType()->isIntOrIntVectorTy()) && "ComputeNumSignBits requires a TargetData object to operate " "on non-integer values!"); const Type *Ty = V->getType(); @@ -823,7 +823,7 @@ assert(V && "No Value?"); assert(Depth <= MaxDepth && "Limit Search Depth"); - assert(V->getType()->isInteger() && "Not integer or pointer type!"); + assert(V->getType()->isIntegerTy() && "Not integer or pointer type!"); const Type *T = V->getType(); @@ -1372,7 +1372,7 @@ // Make sure the index-ee is a pointer to array of i8. const PointerType *PT = cast(GEP->getOperand(0)->getType()); const ArrayType *AT = dyn_cast(PT->getElementType()); - if (AT == 0 || !AT->getElementType()->isInteger(8)) + if (AT == 0 || !AT->getElementType()->isIntegerTy(8)) return false; // Check to make sure that the first operand of the GEP is an integer and @@ -1411,7 +1411,7 @@ // Must be a Constant Array ConstantArray *Array = dyn_cast(GlobalInit); - if (Array == 0 || !Array->getType()->getElementType()->isInteger(8)) + if (Array == 0 || !Array->getType()->getElementType()->isIntegerTy(8)) return false; // Get the number of elements in the array Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Feb 15 10:12:20 2010 @@ -2057,8 +2057,8 @@ if (Elts.empty()) return Error(ID.Loc, "constant vector must not be empty"); - if (!Elts[0]->getType()->isInteger() && - !Elts[0]->getType()->isFloatingPoint()) + if (!Elts[0]->getType()->isIntegerTy() && + !Elts[0]->getType()->isFloatingPointTy()) return Error(FirstEltLoc, "vector elements must have integer or floating point type"); @@ -2250,12 +2250,12 @@ CmpInst::Predicate Pred = (CmpInst::Predicate)PredVal; if (Opc == Instruction::FCmp) { - if (!Val0->getType()->isFPOrFPVector()) + if (!Val0->getType()->isFPOrFPVectorTy()) return Error(ID.Loc, "fcmp requires floating point operands"); ID.ConstantVal = ConstantExpr::getFCmp(Pred, Val0, Val1); } else { assert(Opc == Instruction::ICmp && "Unexpected opcode for CmpInst!"); - if (!Val0->getType()->isIntOrIntVector() && + if (!Val0->getType()->isIntOrIntVectorTy() && !isa(Val0->getType())) return Error(ID.Loc, "icmp requires pointer or integer operands"); ID.ConstantVal = ConstantExpr::getICmp(Pred, Val0, Val1); @@ -2306,7 +2306,7 @@ return true; if (Val0->getType() != Val1->getType()) return Error(ID.Loc, "operands of constexpr must have same type"); - if (!Val0->getType()->isIntOrIntVector()) { + if (!Val0->getType()->isIntOrIntVectorTy()) { if (NUW) return Error(ModifierLoc, "nuw only applies to integer operations"); if (NSW) @@ -2314,8 +2314,8 @@ } // API compatibility: Accept either integer or floating-point types with // add, sub, and mul. - if (!Val0->getType()->isIntOrIntVector() && - !Val0->getType()->isFPOrFPVector()) + if (!Val0->getType()->isIntOrIntVectorTy() && + !Val0->getType()->isFPOrFPVectorTy()) return Error(ID.Loc,"constexpr requires integer, fp, or vector operands"); unsigned Flags = 0; if (NUW) Flags |= OverflowingBinaryOperator::NoUnsignedWrap; @@ -2345,7 +2345,7 @@ return true; if (Val0->getType() != Val1->getType()) return Error(ID.Loc, "operands of constexpr must have same type"); - if (!Val0->getType()->isIntOrIntVector()) + if (!Val0->getType()->isIntOrIntVectorTy()) return Error(ID.Loc, "constexpr requires integer or integer vector operands"); ID.ConstantVal = ConstantExpr::get(Opc, Val0, Val1); @@ -2515,7 +2515,7 @@ V = ConstantInt::get(Context, ID.APSIntVal); return false; case ValID::t_APFloat: - if (!Ty->isFloatingPoint() || + if (!Ty->isFloatingPointTy() || !ConstantFP::isValueValidForType(Ty, ID.APFloatVal)) return Error(ID.Loc, "floating point constant invalid for type"); @@ -2963,7 +2963,7 @@ // API compatibility: Accept either integer or floating-point types. bool Result = ParseArithmetic(Inst, PFS, KeywordVal, 0); if (!Result) { - if (!Inst->getType()->isIntOrIntVector()) { + if (!Inst->getType()->isIntOrIntVectorTy()) { if (NUW) return Error(ModifierLoc, "nuw only applies to integer operations"); if (NSW) @@ -3382,11 +3382,11 @@ switch (OperandType) { default: llvm_unreachable("Unknown operand type!"); case 0: // int or FP. - Valid = LHS->getType()->isIntOrIntVector() || - LHS->getType()->isFPOrFPVector(); + Valid = LHS->getType()->isIntOrIntVectorTy() || + LHS->getType()->isFPOrFPVectorTy(); break; - case 1: Valid = LHS->getType()->isIntOrIntVector(); break; - case 2: Valid = LHS->getType()->isFPOrFPVector(); break; + case 1: Valid = LHS->getType()->isIntOrIntVectorTy(); break; + case 2: Valid = LHS->getType()->isFPOrFPVectorTy(); break; } if (!Valid) @@ -3406,7 +3406,7 @@ ParseValue(LHS->getType(), RHS, PFS)) return true; - if (!LHS->getType()->isIntOrIntVector()) + if (!LHS->getType()->isIntOrIntVectorTy()) return Error(Loc,"instruction requires integer or integer vector operands"); Inst = BinaryOperator::Create((Instruction::BinaryOps)Opc, LHS, RHS); @@ -3430,12 +3430,12 @@ return true; if (Opc == Instruction::FCmp) { - if (!LHS->getType()->isFPOrFPVector()) + if (!LHS->getType()->isFPOrFPVectorTy()) return Error(Loc, "fcmp requires floating point operands"); Inst = new FCmpInst(CmpInst::Predicate(Pred), LHS, RHS); } else { assert(Opc == Instruction::ICmp && "Unknown opcode for CmpInst!"); - if (!LHS->getType()->isIntOrIntVector() && + if (!LHS->getType()->isIntOrIntVectorTy() && !isa(LHS->getType())) return Error(Loc, "icmp requires integer operands"); Inst = new ICmpInst(CmpInst::Predicate(Pred), LHS, RHS); @@ -3733,7 +3733,7 @@ } } - if (Size && !Size->getType()->isInteger(32)) + if (Size && !Size->getType()->isIntegerTy(32)) return Error(SizeLoc, "element count must be i32"); if (isAlloca) { Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Feb 15 10:12:20 2010 @@ -108,17 +108,17 @@ switch (Val) { default: return -1; case bitc::BINOP_ADD: - return Ty->isFPOrFPVector() ? Instruction::FAdd : Instruction::Add; + return Ty->isFPOrFPVectorTy() ? Instruction::FAdd : Instruction::Add; case bitc::BINOP_SUB: - return Ty->isFPOrFPVector() ? Instruction::FSub : Instruction::Sub; + return Ty->isFPOrFPVectorTy() ? Instruction::FSub : Instruction::Sub; case bitc::BINOP_MUL: - return Ty->isFPOrFPVector() ? Instruction::FMul : Instruction::Mul; + return Ty->isFPOrFPVectorTy() ? Instruction::FMul : Instruction::Mul; case bitc::BINOP_UDIV: return Instruction::UDiv; case bitc::BINOP_SDIV: - return Ty->isFPOrFPVector() ? Instruction::FDiv : Instruction::SDiv; + return Ty->isFPOrFPVectorTy() ? Instruction::FDiv : Instruction::SDiv; case bitc::BINOP_UREM: return Instruction::URem; case bitc::BINOP_SREM: - return Ty->isFPOrFPVector() ? Instruction::FRem : Instruction::SRem; + return Ty->isFPOrFPVectorTy() ? Instruction::FRem : Instruction::SRem; case bitc::BINOP_SHL: return Instruction::Shl; case bitc::BINOP_LSHR: return Instruction::LShr; case bitc::BINOP_ASHR: return Instruction::AShr; @@ -1175,7 +1175,7 @@ Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); - if (OpTy->isFPOrFPVector()) + if (OpTy->isFPOrFPVectorTy()) V = ConstantExpr::getFCmp(Record[3], Op0, Op1); else V = ConstantExpr::getICmp(Record[3], Op0, Op1); @@ -1892,7 +1892,7 @@ OpNum+1 != Record.size()) return Error("Invalid CMP record"); - if (LHS->getType()->isFPOrFPVector()) + if (LHS->getType()->isFPOrFPVectorTy()) I = new FCmpInst((FCmpInst::Predicate)Record[OpNum], LHS, RHS); else I = new ICmpInst((ICmpInst::Predicate)Record[OpNum], LHS, RHS); Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Mon Feb 15 10:12:20 2010 @@ -155,7 +155,7 @@ /// LowerBSWAP - Emit the code to lower bswap of V before the specified /// instruction IP. static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) { - assert(V->getType()->isInteger() && "Can't bswap a non-integer type!"); + assert(V->getType()->isIntegerTy() && "Can't bswap a non-integer type!"); unsigned BitSize = V->getType()->getPrimitiveSizeInBits(); @@ -251,7 +251,7 @@ /// LowerCTPOP - Emit the code to lower ctpop of V before the specified /// instruction IP. static Value *LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP) { - assert(V->getType()->isInteger() && "Can't ctpop a non-integer type!"); + assert(V->getType()->isIntegerTy() && "Can't ctpop a non-integer type!"); static const uint64_t MaskValues[6] = { 0x5555555555555555ULL, 0x3333333333333333ULL, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Feb 15 10:12:20 2010 @@ -4631,7 +4631,7 @@ StringRef Name = F->getName(); if (Name == "copysign" || Name == "copysignf") { if (I.getNumOperands() == 3 && // Basic sanity checks. - I.getOperand(1)->getType()->isFloatingPoint() && + I.getOperand(1)->getType()->isFloatingPointTy() && I.getType() == I.getOperand(1)->getType() && I.getType() == I.getOperand(2)->getType()) { SDValue LHS = getValue(I.getOperand(1)); @@ -4642,7 +4642,7 @@ } } else if (Name == "fabs" || Name == "fabsf" || Name == "fabsl") { if (I.getNumOperands() == 2 && // Basic sanity checks. - I.getOperand(1)->getType()->isFloatingPoint() && + I.getOperand(1)->getType()->isFloatingPointTy() && I.getType() == I.getOperand(1)->getType()) { SDValue Tmp = getValue(I.getOperand(1)); setValue(&I, DAG.getNode(ISD::FABS, getCurDebugLoc(), @@ -4651,7 +4651,7 @@ } } else if (Name == "sin" || Name == "sinf" || Name == "sinl") { if (I.getNumOperands() == 2 && // Basic sanity checks. - I.getOperand(1)->getType()->isFloatingPoint() && + I.getOperand(1)->getType()->isFloatingPointTy() && I.getType() == I.getOperand(1)->getType() && I.onlyReadsMemory()) { SDValue Tmp = getValue(I.getOperand(1)); @@ -4661,7 +4661,7 @@ } } else if (Name == "cos" || Name == "cosf" || Name == "cosl") { if (I.getNumOperands() == 2 && // Basic sanity checks. - I.getOperand(1)->getType()->isFloatingPoint() && + I.getOperand(1)->getType()->isFloatingPointTy() && I.getType() == I.getOperand(1)->getType() && I.onlyReadsMemory()) { SDValue Tmp = getValue(I.getOperand(1)); @@ -4671,7 +4671,7 @@ } } else if (Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl") { if (I.getNumOperands() == 2 && // Basic sanity checks. - I.getOperand(1)->getType()->isFloatingPoint() && + I.getOperand(1)->getType()->isFloatingPointTy() && I.getType() == I.getOperand(1)->getType() && I.onlyReadsMemory()) { SDValue Tmp = getValue(I.getOperand(1)); Modified: llvm/trunk/lib/CodeGen/StackProtector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackProtector.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StackProtector.cpp (original) +++ llvm/trunk/lib/CodeGen/StackProtector.cpp Mon Feb 15 10:12:20 2010 @@ -113,7 +113,7 @@ if (const ArrayType *AT = dyn_cast(AI->getAllocatedType())) { // We apparently only care about character arrays. - if (!AT->getElementType()->isInteger(8)) + if (!AT->getElementType()->isIntegerTy(8)) continue; // If an array has more than SSPBufferSize bytes of allocated space, Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Mon Feb 15 10:12:20 2010 @@ -339,7 +339,7 @@ } // FALLS THROUGH case 1: - if (!FTy->getParamType(0)->isInteger(32)) { + if (!FTy->getParamType(0)->isIntegerTy(32)) { llvm_report_error("Invalid type for first argument of main() supplied"); } // FALLS THROUGH @@ -599,18 +599,18 @@ switch (Op0->getType()->getTypeID()) { default: llvm_unreachable("Invalid bitcast operand"); case Type::IntegerTyID: - assert(DestTy->isFloatingPoint() && "invalid bitcast"); + assert(DestTy->isFloatingPointTy() && "invalid bitcast"); if (DestTy->isFloatTy()) GV.FloatVal = GV.IntVal.bitsToFloat(); else if (DestTy->isDoubleTy()) GV.DoubleVal = GV.IntVal.bitsToDouble(); break; case Type::FloatTyID: - assert(DestTy->isInteger(32) && "Invalid bitcast"); + assert(DestTy->isIntegerTy(32) && "Invalid bitcast"); GV.IntVal.floatToBits(GV.FloatVal); break; case Type::DoubleTyID: - assert(DestTy->isInteger(64) && "Invalid bitcast"); + assert(DestTy->isIntegerTy(64) && "Invalid bitcast"); GV.IntVal.doubleToBits(GV.DoubleVal); break; case Type::PointerTyID: Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp Mon Feb 15 10:12:20 2010 @@ -591,7 +591,7 @@ ECStack.pop_back(); if (ECStack.empty()) { // Finished main. Put result into exit code... - if (RetTy && RetTy->isInteger()) { // Nonvoid return type? + if (RetTy && RetTy->isIntegerTy()) { // Nonvoid return type? ExitValue = Result; // Capture the exit value of the program } else { memset(&ExitValue.Untyped, 0, sizeof(ExitValue.Untyped)); @@ -979,7 +979,7 @@ const Type *SrcTy = SrcVal->getType(); uint32_t DBitWidth = cast(DstTy)->getBitWidth(); GenericValue Dest, Src = getOperandValue(SrcVal, SF); - assert(SrcTy->isFloatingPoint() && "Invalid FPToUI instruction"); + assert(SrcTy->isFloatingPointTy() && "Invalid FPToUI instruction"); if (SrcTy->getTypeID() == Type::FloatTyID) Dest.IntVal = APIntOps::RoundFloatToAPInt(Src.FloatVal, DBitWidth); @@ -993,7 +993,7 @@ const Type *SrcTy = SrcVal->getType(); uint32_t DBitWidth = cast(DstTy)->getBitWidth(); GenericValue Dest, Src = getOperandValue(SrcVal, SF); - assert(SrcTy->isFloatingPoint() && "Invalid FPToSI instruction"); + assert(SrcTy->isFloatingPointTy() && "Invalid FPToSI instruction"); if (SrcTy->getTypeID() == Type::FloatTyID) Dest.IntVal = APIntOps::RoundFloatToAPInt(Src.FloatVal, DBitWidth); @@ -1005,7 +1005,7 @@ GenericValue Interpreter::executeUIToFPInst(Value *SrcVal, const Type *DstTy, ExecutionContext &SF) { GenericValue Dest, Src = getOperandValue(SrcVal, SF); - assert(DstTy->isFloatingPoint() && "Invalid UIToFP instruction"); + assert(DstTy->isFloatingPointTy() && "Invalid UIToFP instruction"); if (DstTy->getTypeID() == Type::FloatTyID) Dest.FloatVal = APIntOps::RoundAPIntToFloat(Src.IntVal); @@ -1017,7 +1017,7 @@ GenericValue Interpreter::executeSIToFPInst(Value *SrcVal, const Type *DstTy, ExecutionContext &SF) { GenericValue Dest, Src = getOperandValue(SrcVal, SF); - assert(DstTy->isFloatingPoint() && "Invalid SIToFP instruction"); + assert(DstTy->isFloatingPointTy() && "Invalid SIToFP instruction"); if (DstTy->getTypeID() == Type::FloatTyID) Dest.FloatVal = APIntOps::RoundSignedAPIntToFloat(Src.IntVal); @@ -1058,24 +1058,24 @@ if (isa(DstTy)) { assert(isa(SrcTy) && "Invalid BitCast"); Dest.PointerVal = Src.PointerVal; - } else if (DstTy->isInteger()) { + } else if (DstTy->isIntegerTy()) { if (SrcTy->isFloatTy()) { Dest.IntVal.zext(sizeof(Src.FloatVal) * CHAR_BIT); Dest.IntVal.floatToBits(Src.FloatVal); } else if (SrcTy->isDoubleTy()) { Dest.IntVal.zext(sizeof(Src.DoubleVal) * CHAR_BIT); Dest.IntVal.doubleToBits(Src.DoubleVal); - } else if (SrcTy->isInteger()) { + } else if (SrcTy->isIntegerTy()) { Dest.IntVal = Src.IntVal; } else llvm_unreachable("Invalid BitCast"); } else if (DstTy->isFloatTy()) { - if (SrcTy->isInteger()) + if (SrcTy->isIntegerTy()) Dest.FloatVal = Src.IntVal.bitsToFloat(); else Dest.FloatVal = Src.FloatVal; } else if (DstTy->isDoubleTy()) { - if (SrcTy->isInteger()) + if (SrcTy->isIntegerTy()) Dest.DoubleVal = Src.IntVal.bitsToDouble(); else Dest.DoubleVal = Src.DoubleVal; Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Mon Feb 15 10:12:20 2010 @@ -411,10 +411,10 @@ // Handle some common cases first. These cases correspond to common `main' // prototypes. - if (RetTy->isInteger(32) || RetTy->isVoidTy()) { + if (RetTy->isIntegerTy(32) || RetTy->isVoidTy()) { switch (ArgValues.size()) { case 3: - if (FTy->getParamType(0)->isInteger(32) && + if (FTy->getParamType(0)->isIntegerTy(32) && isa(FTy->getParamType(1)) && isa(FTy->getParamType(2))) { int (*PF)(int, char **, const char **) = @@ -429,7 +429,7 @@ } break; case 2: - if (FTy->getParamType(0)->isInteger(32) && + if (FTy->getParamType(0)->isIntegerTy(32) && isa(FTy->getParamType(1))) { int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr; @@ -442,7 +442,7 @@ break; case 1: if (FTy->getNumParams() == 1 && - FTy->getParamType(0)->isInteger(32)) { + FTy->getParamType(0)->isIntegerTy(32)) { GenericValue rv; int (*PF)(int) = (int(*)(int))(intptr_t)FPtr; rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue())); Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Mon Feb 15 10:12:20 2010 @@ -493,7 +493,7 @@ CWriter::printSimpleType(formatted_raw_ostream &Out, const Type *Ty, bool isSigned, const std::string &NameSoFar) { - assert((Ty->isPrimitiveType() || Ty->isInteger() || isa(Ty)) && + assert((Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) && "Invalid type for printSimpleType"); switch (Ty->getTypeID()) { case Type::VoidTyID: return Out << "void " << NameSoFar; @@ -540,7 +540,7 @@ std::ostream & CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned, const std::string &NameSoFar) { - assert((Ty->isPrimitiveType() || Ty->isInteger() || isa(Ty)) && + assert((Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) && "Invalid type for printSimpleType"); switch (Ty->getTypeID()) { case Type::VoidTyID: return Out << "void " << NameSoFar; @@ -591,7 +591,7 @@ const Type *Ty, bool isSigned, const std::string &NameSoFar, bool IgnoreName, const AttrListPtr &PAL) { - if (Ty->isPrimitiveType() || Ty->isInteger() || isa(Ty)) { + if (Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) { printSimpleType(Out, Ty, isSigned, NameSoFar); return Out; } @@ -694,7 +694,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty, bool isSigned, const std::string &NameSoFar, bool IgnoreName, const AttrListPtr &PAL) { - if (Ty->isPrimitiveType() || Ty->isInteger() || isa(Ty)) { + if (Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) { printSimpleType(Out, Ty, isSigned, NameSoFar); return Out; } @@ -1396,7 +1396,7 @@ } if (NeedsExplicitCast) { Out << "(("; - if (Ty->isInteger() && Ty != Type::getInt1Ty(Ty->getContext())) + if (Ty->isIntegerTy() && Ty != Type::getInt1Ty(Ty->getContext())) printSimpleType(Out, Ty, TypeIsSigned); else printType(Out, Ty); // not integer, sign doesn't matter @@ -1497,7 +1497,7 @@ // We can't currently support integer types other than 1, 8, 16, 32, 64. // Validate this. const Type *Ty = I.getType(); - if (Ty->isInteger() && (Ty!=Type::getInt1Ty(I.getContext()) && + if (Ty->isIntegerTy() && (Ty!=Type::getInt1Ty(I.getContext()) && Ty!=Type::getInt8Ty(I.getContext()) && Ty!=Type::getInt16Ty(I.getContext()) && Ty!=Type::getInt32Ty(I.getContext()) && @@ -2287,7 +2287,8 @@ void CWriter::printContainedStructs(const Type *Ty, std::set &StructPrinted) { // Don't walk through pointers. - if (isa(Ty) || Ty->isPrimitiveType() || Ty->isInteger()) return; + if (isa(Ty) || Ty->isPrimitiveType() || Ty->isIntegerTy()) + return; // Print all contained types first. for (Type::subtype_iterator I = Ty->subtype_begin(), @@ -2423,8 +2424,8 @@ return false; const Type *SrcTy = I.getOperand(0)->getType(); const Type *DstTy = I.getType(); - return (SrcTy->isFloatingPoint() && DstTy->isInteger()) || - (DstTy->isFloatingPoint() && SrcTy->isInteger()); + return (SrcTy->isFloatingPointTy() && DstTy->isIntegerTy()) || + (DstTy->isFloatingPointTy() && SrcTy->isIntegerTy()); } void CWriter::printFunction(Function &F) { Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Feb 15 10:12:20 2010 @@ -344,7 +344,7 @@ std::string CppWriter::getCppName(const Type* Ty) { // First, handle the primitive types .. easy - if (Ty->isPrimitiveType() || Ty->isInteger()) { + if (Ty->isPrimitiveType() || Ty->isIntegerTy()) { switch (Ty->getTypeID()) { case Type::VoidTyID: return "Type::getVoidTy(getGlobalContext())"; case Type::IntegerTyID: { @@ -493,7 +493,7 @@ bool CppWriter::printTypeInternal(const Type* Ty) { // We don't print definitions for primitive types - if (Ty->isPrimitiveType() || Ty->isInteger()) + if (Ty->isPrimitiveType() || Ty->isIntegerTy()) return false; // If we already defined this type, we don't need to define it again. @@ -686,7 +686,7 @@ // For primitive types and types already defined, just add a name TypeMap::const_iterator TNI = TypeNames.find(TI->second); - if (TI->second->isInteger() || TI->second->isPrimitiveType() || + if (TI->second->isIntegerTy() || TI->second->isPrimitiveType() || TNI != TypeNames.end()) { Out << "mod->addTypeName(\""; printEscapedString(TI->first); Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Mon Feb 15 10:12:20 2010 @@ -187,7 +187,7 @@ break; case 1: Arg1 = F->arg_begin(); - if (Arg1->getType()->isInteger()) { + if (Arg1->getType()->isIntegerTy()) { Out << "\tldloc\targc\n"; Args = getTypeName(Arg1->getType()); BadSig = false; @@ -195,7 +195,7 @@ break; case 2: Arg1 = Arg2 = F->arg_begin(); ++Arg2; - if (Arg1->getType()->isInteger() && + if (Arg1->getType()->isIntegerTy() && Arg2->getType()->getTypeID() == Type::PointerTyID) { Out << "\tldloc\targc\n\tldloc\targv\n"; Args = getTypeName(Arg1->getType())+","+getTypeName(Arg2->getType()); @@ -207,7 +207,7 @@ } bool RetVoid = (F->getReturnType()->getTypeID() == Type::VoidTyID); - if (BadSig || (!F->getReturnType()->isInteger() && !RetVoid)) { + if (BadSig || (!F->getReturnType()->isIntegerTy() && !RetVoid)) { Out << "\tldc.i4.0\n"; } else { Out << "\tcall\t" << getTypeName(F->getReturnType()) << @@ -334,7 +334,7 @@ std::string MSILWriter::getTypeName(const Type* Ty, bool isSigned, bool isNested) { - if (Ty->isPrimitiveType() || Ty->isInteger()) + if (Ty->isPrimitiveType() || Ty->isIntegerTy()) return getPrimitiveTypeName(Ty,isSigned); // FIXME: "OpaqueType" support switch (Ty->getTypeID()) { Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Mon Feb 15 10:12:20 2010 @@ -971,7 +971,7 @@ bool MSP430TargetLowering::isTruncateFree(const Type *Ty1, const Type *Ty2) const { - if (!Ty1->isInteger() || !Ty2->isInteger()) + if (!Ty1->isIntegerTy() || !Ty2->isIntegerTy()) return false; return (Ty1->getPrimitiveSizeInBits() > Ty2->getPrimitiveSizeInBits()); @@ -986,7 +986,7 @@ bool MSP430TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const { // MSP430 implicitly zero-extends 8-bit results in 16-bit registers. - return 0 && Ty1->isInteger(8) && Ty2->isInteger(16); + return 0 && Ty1->isIntegerTy(8) && Ty2->isIntegerTy(16); } bool MSP430TargetLowering::isZExtFree(EVT VT1, EVT VT2) const { Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon Feb 15 10:12:20 2010 @@ -786,8 +786,8 @@ bool X86FastISel::X86SelectZExt(Instruction *I) { // Handle zero-extension from i1 to i8, which is common. - if (I->getType()->isInteger(8) && - I->getOperand(0)->getType()->isInteger(1)) { + if (I->getType()->isIntegerTy(8) && + I->getOperand(0)->getType()->isIntegerTy(1)) { unsigned ResultReg = getRegForValue(I->getOperand(0)); if (ResultReg == 0) return false; // Set the high bits to zero. @@ -949,7 +949,7 @@ bool X86FastISel::X86SelectShift(Instruction *I) { unsigned CReg = 0, OpReg = 0, OpImm = 0; const TargetRegisterClass *RC = NULL; - if (I->getType()->isInteger(8)) { + if (I->getType()->isIntegerTy(8)) { CReg = X86::CL; RC = &X86::GR8RegClass; switch (I->getOpcode()) { @@ -958,7 +958,7 @@ case Instruction::Shl: OpReg = X86::SHL8rCL; OpImm = X86::SHL8ri; break; default: return false; } - } else if (I->getType()->isInteger(16)) { + } else if (I->getType()->isIntegerTy(16)) { CReg = X86::CX; RC = &X86::GR16RegClass; switch (I->getOpcode()) { @@ -967,7 +967,7 @@ case Instruction::Shl: OpReg = X86::SHL16rCL; OpImm = X86::SHL16ri; break; default: return false; } - } else if (I->getType()->isInteger(32)) { + } else if (I->getType()->isIntegerTy(32)) { CReg = X86::ECX; RC = &X86::GR32RegClass; switch (I->getOpcode()) { @@ -976,7 +976,7 @@ case Instruction::Shl: OpReg = X86::SHL32rCL; OpImm = X86::SHL32ri; break; default: return false; } - } else if (I->getType()->isInteger(64)) { + } else if (I->getType()->isIntegerTy(64)) { CReg = X86::RCX; RC = &X86::GR64RegClass; switch (I->getOpcode()) { Modified: llvm/trunk/lib/Target/X86/X86FloatingPointRegKill.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FloatingPointRegKill.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FloatingPointRegKill.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FloatingPointRegKill.cpp Mon Feb 15 10:12:20 2010 @@ -118,7 +118,7 @@ for (BasicBlock::const_iterator II = SI->begin(); (PN = dyn_cast(II)); ++II) { if (PN->getType()==Type::getX86_FP80Ty(LLVMBB->getContext()) || - (!Subtarget.hasSSE1() && PN->getType()->isFloatingPoint()) || + (!Subtarget.hasSSE1() && PN->getType()->isFloatingPointTy()) || (!Subtarget.hasSSE2() && PN->getType()==Type::getDoubleTy(LLVMBB->getContext()))) { ContainsFPCode = true; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb 15 10:12:20 2010 @@ -7742,7 +7742,7 @@ bool X86TargetLowering::isTruncateFree(const Type *Ty1, const Type *Ty2) const { - if (!Ty1->isInteger() || !Ty2->isInteger()) + if (!Ty1->isIntegerTy() || !Ty2->isIntegerTy()) return false; unsigned NumBits1 = Ty1->getPrimitiveSizeInBits(); unsigned NumBits2 = Ty2->getPrimitiveSizeInBits(); @@ -7763,7 +7763,7 @@ bool X86TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const { // x86-64 implicitly zero-extends 32-bit results in 64-bit registers. - return Ty1->isInteger(32) && Ty2->isInteger(64) && Subtarget->is64Bit(); + return Ty1->isIntegerTy(32) && Ty2->isIntegerTy(64) && Subtarget->is64Bit(); } bool X86TargetLowering::isZExtFree(EVT VT1, EVT VT2) const { @@ -9695,7 +9695,7 @@ // Verify this is a simple bswap. if (CI->getNumOperands() != 2 || CI->getType() != CI->getOperand(1)->getType() || - !CI->getType()->isInteger()) + !CI->getType()->isIntegerTy()) return false; const IntegerType *Ty = dyn_cast(CI->getType()); @@ -9744,7 +9744,7 @@ return LowerToBSwap(CI); } // rorw $$8, ${0:w} --> llvm.bswap.i16 - if (CI->getType()->isInteger(16) && + if (CI->getType()->isIntegerTy(16) && AsmPieces.size() == 3 && AsmPieces[0] == "rorw" && AsmPieces[1] == "$$8," && @@ -9754,7 +9754,7 @@ } break; case 3: - if (CI->getType()->isInteger(64) && + if (CI->getType()->isIntegerTy(64) && Constraints.size() >= 2 && Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" && Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") { Modified: llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadTypeElimination.cpp Mon Feb 15 10:12:20 2010 @@ -57,13 +57,13 @@ // static inline bool ShouldNukeSymtabEntry(const Type *Ty){ // Nuke all names for primitive types! - if (Ty->isPrimitiveType() || Ty->isInteger()) + if (Ty->isPrimitiveType() || Ty->isIntegerTy()) return true; // Nuke all pointers to primitive types as well... if (const PointerType *PT = dyn_cast(Ty)) if (PT->getElementType()->isPrimitiveType() || - PT->getElementType()->isInteger()) + PT->getElementType()->isIntegerTy()) return true; return false; Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Feb 15 10:12:20 2010 @@ -1590,7 +1590,7 @@ // simplification. In these cases, we typically end up with "cond ? v1 : v2" // where v1 and v2 both require constant pool loads, a big loss. if (GVElType == Type::getInt1Ty(GV->getContext()) || - GVElType->isFloatingPoint() || + GVElType->isFloatingPointTy() || isa(GVElType) || isa(GVElType)) return false; @@ -1925,7 +1925,7 @@ if (!ATy) return 0; const StructType *STy = dyn_cast(ATy->getElementType()); if (!STy || STy->getNumElements() != 2 || - !STy->getElementType(0)->isInteger(32)) return 0; + !STy->getElementType(0)->isIntegerTy(32)) return 0; const PointerType *PFTy = dyn_cast(STy->getElementType(1)); if (!PFTy) return 0; const FunctionType *FTy = dyn_cast(PFTy->getElementType()); Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Mon Feb 15 10:12:20 2010 @@ -35,7 +35,7 @@ // Otherwise, return null. // static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST) { - if (!V->hasOneUse() || !V->getType()->isInteger()) + if (!V->hasOneUse() || !V->getType()->isIntegerTy()) return 0; Instruction *I = dyn_cast(V); @@ -145,10 +145,10 @@ } } - if (I.getType()->isInteger(1)) + if (I.getType()->isIntegerTy(1)) return BinaryOperator::CreateXor(LHS, RHS); - if (I.getType()->isInteger()) { + if (I.getType()->isIntegerTy()) { // X + X --> X << 1 if (LHS == RHS) return BinaryOperator::CreateShl(LHS, ConstantInt::get(I.getType(), 1)); @@ -168,7 +168,7 @@ // -A + B --> B - A // -A + -B --> -(A + B) if (Value *LHSV = dyn_castNegVal(LHS)) { - if (LHS->getType()->isIntOrIntVector()) { + if (LHS->getType()->isIntOrIntVectorTy()) { if (Value *RHSV = dyn_castNegVal(RHS)) { Value *NewAdd = Builder->CreateAdd(LHSV, RHSV, "sum"); return BinaryOperator::CreateNeg(NewAdd); @@ -222,7 +222,7 @@ } // W*X + Y*Z --> W * (X+Z) iff W == Y - if (I.getType()->isIntOrIntVector()) { + if (I.getType()->isIntOrIntVectorTy()) { Value *W, *X, *Y, *Z; if (match(LHS, m_Mul(m_Value(W), m_Value(X))) && match(RHS, m_Mul(m_Value(Y), m_Value(Z)))) { @@ -560,7 +560,7 @@ return ReplaceInstUsesWith(I, Op0); // undef - X -> undef if (isa(Op1)) return ReplaceInstUsesWith(I, Op1); // X - undef -> undef - if (I.getType()->isInteger(1)) + if (I.getType()->isIntegerTy(1)) return BinaryOperator::CreateXor(Op0, Op1); if (ConstantInt *C = dyn_cast(Op0)) { Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Feb 15 10:12:20 2010 @@ -946,7 +946,7 @@ const Type *SrcTy = Op0C->getOperand(0)->getType(); if (Op0C->getOpcode() == Op1C->getOpcode() && // same cast kind ? SrcTy == Op1C->getOperand(0)->getType() && - SrcTy->isIntOrIntVector()) { + SrcTy->isIntOrIntVectorTy()) { Value *Op0COp = Op0C->getOperand(0), *Op1COp = Op1C->getOperand(0); // Only do this if the casts both really cause code to be generated. @@ -1161,7 +1161,7 @@ // If A is not a select of -1/0, this cannot match. Value *Cond = 0; if (!match(A, m_SExt(m_Value(Cond))) || - !Cond->getType()->isInteger(1)) + !Cond->getType()->isIntegerTy(1)) return 0; // ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B. @@ -1699,7 +1699,7 @@ if (Op0C->getOpcode() == Op1C->getOpcode()) {// same cast kind ? const Type *SrcTy = Op0C->getOperand(0)->getType(); if (SrcTy == Op1C->getOperand(0)->getType() && - SrcTy->isIntOrIntVector()) { + SrcTy->isIntOrIntVectorTy()) { Value *Op0COp = Op0C->getOperand(0), *Op1COp = Op1C->getOperand(0); if ((!isa(Op0COp) || !isa(Op1COp)) && @@ -2016,7 +2016,7 @@ if (CastInst *Op1C = dyn_cast(Op1)) if (Op0C->getOpcode() == Op1C->getOpcode()) { // same cast kind? const Type *SrcTy = Op0C->getOperand(0)->getType(); - if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isInteger() && + if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegerTy() && // Only do this if the casts both really cause code to be generated. ShouldOptimizeCast(Op0C->getOpcode(), Op0C->getOperand(0), I.getType()) && Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Feb 15 10:12:20 2010 @@ -199,7 +199,7 @@ // Extract the length and alignment and fill if they are constant. ConstantInt *LenC = dyn_cast(MI->getLength()); ConstantInt *FillC = dyn_cast(MI->getValue()); - if (!LenC || !FillC || !FillC->getType()->isInteger(8)) + if (!LenC || !FillC || !FillC->getType()->isIntegerTy(8)) return 0; uint64_t Len = LenC->getZExtValue(); Alignment = MI->getAlignment(); Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Mon Feb 15 10:12:20 2010 @@ -23,7 +23,7 @@ /// static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale, int &Offset) { - assert(Val->getType()->isInteger(32) && "Unexpected allocation size type!"); + assert(Val->getType()->isIntegerTy(32) && "Unexpected allocation size type!"); if (ConstantInt *CI = dyn_cast(Val)) { Offset = CI->getZExtValue(); Scale = 0; @@ -837,7 +837,7 @@ // zext (xor i1 X, true) to i32 --> xor (zext i1 X to i32), 1 Value *X; - if (SrcI && SrcI->hasOneUse() && SrcI->getType()->isInteger(1) && + if (SrcI && SrcI->hasOneUse() && SrcI->getType()->isIntegerTy(1) && match(SrcI, m_Not(m_Value(X))) && (!X->hasOneUse() || !isa(X))) { Value *New = Builder->CreateZExt(X, CI.getType()); Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Feb 15 10:12:20 2010 @@ -1606,7 +1606,7 @@ const Type *Ty = Op0->getType(); // icmp's with boolean values can always be turned into bitwise operations - if (Ty->isInteger(1)) { + if (Ty->isIntegerTy(1)) { switch (I.getPredicate()) { default: llvm_unreachable("Invalid icmp instruction!"); case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B) @@ -1650,7 +1650,7 @@ unsigned BitWidth = 0; if (TD) BitWidth = TD->getTypeSizeInBits(Ty->getScalarType()); - else if (Ty->isIntOrIntVector()) + else if (Ty->isIntOrIntVectorTy()) BitWidth = Ty->getScalarSizeInBits(); bool isSignBit = false; Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Mon Feb 15 10:12:20 2010 @@ -87,7 +87,7 @@ const Type *SrcPTy = SrcTy->getElementType(); - if (DestPTy->isInteger() || isa(DestPTy) || + if (DestPTy->isIntegerTy() || isa(DestPTy) || isa(DestPTy)) { // If the source is an array, the code below will not succeed. Check to // see if a trivial 'gep P, 0, 0' will help matters. Only do this for @@ -104,7 +104,7 @@ } if (IC.getTargetData() && - (SrcPTy->isInteger() || isa(SrcPTy) || + (SrcPTy->isIntegerTy() || isa(SrcPTy) || isa(SrcPTy)) && // Do not allow turning this into a load of an integer, which is then // casted to a pointer, this pessimizes pointer analysis a lot. @@ -243,7 +243,7 @@ const Type *SrcPTy = SrcTy->getElementType(); - if (!DestPTy->isInteger() && !isa(DestPTy)) + if (!DestPTy->isIntegerTy() && !isa(DestPTy)) return 0; /// NewGEPIndices - If SrcPTy is an aggregate type, we can emit a "noop gep" @@ -277,7 +277,7 @@ SrcTy = PointerType::get(SrcPTy, SrcTy->getAddressSpace()); } - if (!SrcPTy->isInteger() && !isa(SrcPTy)) + if (!SrcPTy->isIntegerTy() && !isa(SrcPTy)) return 0; // If the pointers point into different address spaces or if they point to @@ -298,7 +298,7 @@ const Type* CastSrcTy = SIOp0->getType(); const Type* CastDstTy = SrcPTy; if (isa(CastDstTy)) { - if (CastSrcTy->isInteger()) + if (CastSrcTy->isIntegerTy()) opcode = Instruction::IntToPtr; } else if (isa(CastDstTy)) { if (isa(SIOp0->getType())) Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Mon Feb 15 10:12:20 2010 @@ -157,7 +157,7 @@ } /// i1 mul -> i1 and. - if (I.getType()->isInteger(1)) + if (I.getType()->isIntegerTy(1)) return BinaryOperator::CreateAnd(Op0, Op1); // X*(1 << Y) --> X << Y @@ -314,7 +314,7 @@ // undef / X -> 0 for integer. // undef / X -> undef for FP (the undef could be a snan). if (isa(Op0)) { - if (Op0->getType()->isFPOrFPVector()) + if (Op0->getType()->isFPOrFPVectorTy()) return ReplaceInstUsesWith(I, Op0); return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); } @@ -386,7 +386,7 @@ return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); // It can't be division by zero, hence it must be division by one. - if (I.getType()->isInteger(1)) + if (I.getType()->isIntegerTy(1)) return ReplaceInstUsesWith(I, Op0); if (ConstantVector *Op1V = dyn_cast(Op1)) { @@ -493,7 +493,7 @@ // If the sign bits of both operands are zero (i.e. we can prove they are // unsigned inputs), turn this into a udiv. - if (I.getType()->isInteger()) { + if (I.getType()->isIntegerTy()) { APInt Mask(APInt::getSignBit(I.getType()->getPrimitiveSizeInBits())); if (MaskedValueIsZero(Op0, Mask)) { if (MaskedValueIsZero(Op1, Mask)) { @@ -527,7 +527,7 @@ Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); if (isa(Op0)) { // undef % X -> 0 - if (I.getType()->isFPOrFPVector()) + if (I.getType()->isFPOrFPVectorTy()) return ReplaceInstUsesWith(I, Op0); // X % undef -> undef (could be SNaN) return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); } @@ -648,7 +648,7 @@ // If the sign bits of both operands are zero (i.e. we can prove they are // unsigned inputs), turn this into a urem. - if (I.getType()->isInteger()) { + if (I.getType()->isIntegerTy()) { APInt Mask(APInt::getSignBit(I.getType()->getPrimitiveSizeInBits())); if (MaskedValueIsZero(Op1, Mask) && MaskedValueIsZero(Op0, Mask)) { // X srem Y -> X urem Y, iff X and Y don't have sign bit set Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Mon Feb 15 10:12:20 2010 @@ -441,7 +441,7 @@ return ReplaceInstUsesWith(SI, FalseVal); } - if (SI.getType()->isInteger(1)) { + if (SI.getType()->isIntegerTy(1)) { if (ConstantInt *C = dyn_cast(TrueVal)) { if (C->getZExtValue()) { // Change: A = select B, true, C --> A = or B, C @@ -629,7 +629,7 @@ } // See if we can fold the select into one of our operands. - if (SI.getType()->isInteger()) { + if (SI.getType()->isIntegerTy()) { if (Instruction *FoldI = FoldSelectIntoOp(SI, TrueVal, FalseVal)) return FoldI; Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Mon Feb 15 10:12:20 2010 @@ -107,7 +107,7 @@ assert((TD || !isa(VTy)) && "SimplifyDemandedBits needs to know bit widths!"); assert((!TD || TD->getTypeSizeInBits(VTy->getScalarType()) == BitWidth) && - (!VTy->isIntOrIntVector() || + (!VTy->isIntOrIntVectorTy() || VTy->getScalarSizeInBits() == BitWidth) && KnownZero.getBitWidth() == BitWidth && KnownOne.getBitWidth() == BitWidth && @@ -401,7 +401,7 @@ break; } case Instruction::BitCast: - if (!I->getOperand(0)->getType()->isIntOrIntVector()) + if (!I->getOperand(0)->getType()->isIntOrIntVectorTy()) return 0; // vector->int or fp->int? if (const VectorType *DstVTy = dyn_cast(I->getType())) { Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Mon Feb 15 10:12:20 2010 @@ -158,7 +158,7 @@ return ConstantExpr::getNeg(C); if (ConstantVector *C = dyn_cast(V)) - if (C->getType()->getElementType()->isInteger()) + if (C->getType()->getElementType()->isIntegerTy()) return ConstantExpr::getNeg(C); return 0; @@ -177,7 +177,7 @@ return ConstantExpr::getFNeg(C); if (ConstantVector *C = dyn_cast(V)) - if (C->getType()->getElementType()->isFloatingPoint()) + if (C->getType()->getElementType()->isFloatingPointTy()) return ConstantExpr::getFNeg(C); return 0; @@ -226,7 +226,7 @@ if (isa(TV) || isa(FV)) { // Bool selects with constant operands can be folded to logical ops. - if (SI->getType()->isInteger(1)) return 0; + if (SI->getType()->isIntegerTy(1)) return 0; Value *SelectTrueVal = FoldOperationIntoSelectOperand(Op, TV, this); Value *SelectFalseVal = FoldOperationIntoSelectOperand(Op, FV, this); @@ -596,7 +596,7 @@ // (where tmp = 8*tmp2) into: // getelementptr [100 x double]* %arr, i32 0, i32 %tmp2; bitcast - if (TD && isa(SrcElTy) && ResElTy->isInteger(8)) { + if (TD && isa(SrcElTy) && ResElTy->isIntegerTy(8)) { uint64_t ArrayEltSize = TD->getTypeAllocSize(cast(SrcElTy)->getElementType()); Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Mon Feb 15 10:12:20 2010 @@ -84,7 +84,7 @@ AI = MainFn->arg_begin(); // If the program looked at argc, have it look at the return value of the // init call instead. - if (!AI->getType()->isInteger(32)) { + if (!AI->getType()->isIntegerTy(32)) { Instruction::CastOps opcode; if (!AI->use_empty()) { opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true); Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Feb 15 10:12:20 2010 @@ -405,7 +405,7 @@ // If comparing a live-in value against a constant, see if we know the // live-in value on any predecessors. if (LVI && isa(Cmp->getOperand(1)) && - Cmp->getType()->isInteger() && // Not vector compare. + Cmp->getType()->isIntegerTy() && // Not vector compare. (!isa(Cmp->getOperand(0)) || cast(Cmp->getOperand(0))->getParent() != BB)) { Constant *RHSCst = cast(Cmp->getOperand(1)); Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Mon Feb 15 10:12:20 2010 @@ -871,7 +871,7 @@ // If we know that LIC == Val, or that LIC == NotVal, just replace uses of LIC // in the loop with the appropriate one directly. if (IsEqual || (isa(Val) && - Val->getType()->isInteger(1))) { + Val->getType()->isIntegerTy(1))) { Value *Replacement; if (IsEqual) Replacement = Val; @@ -997,10 +997,10 @@ case Instruction::And: if (isa(I->getOperand(0)) && // constant -> RHS - I->getOperand(0)->getType()->isInteger(1)) + I->getOperand(0)->getType()->isIntegerTy(1)) cast(I)->swapOperands(); if (ConstantInt *CB = dyn_cast(I->getOperand(1))) - if (CB->getType()->isInteger(1)) { + if (CB->getType()->isIntegerTy(1)) { if (CB->isOne()) // X & 1 -> X ReplaceUsesOfWith(I, I->getOperand(0), Worklist, L, LPM); else // X & 0 -> 0 @@ -1011,10 +1011,10 @@ case Instruction::Or: if (isa(I->getOperand(0)) && // constant -> RHS - I->getOperand(0)->getType()->isInteger(1)) + I->getOperand(0)->getType()->isIntegerTy(1)) cast(I)->swapOperands(); if (ConstantInt *CB = dyn_cast(I->getOperand(1))) - if (CB->getType()->isInteger(1)) { + if (CB->getType()->isIntegerTy(1)) { if (CB->isOne()) // X | 1 -> 1 ReplaceUsesOfWith(I, I->getOperand(1), Worklist, L, LPM); else // X | 0 -> X Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Feb 15 10:12:20 2010 @@ -42,7 +42,7 @@ LLVMContext &Context = V->getContext(); // All byte-wide stores are splatable, even of arbitrary variables. - if (V->getType()->isInteger(8)) return V; + if (V->getType()->isIntegerTy(8)) return V; // Constant float and double values can be handled as integer values if the // corresponding integer value is "byteable". An important case is 0.0. Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Mon Feb 15 10:12:20 2010 @@ -182,7 +182,7 @@ // If this is a not or neg instruction, do not count it for rank. This // assures us that X and ~X will have the same rank. - if (!I->getType()->isInteger() || + if (!I->getType()->isIntegerTy() || (!BinaryOperator::isNot(I) && !BinaryOperator::isNeg(I))) ++Rank; @@ -929,7 +929,7 @@ } // Reject cases where it is pointless to do this. - if (!isa(BI) || BI->getType()->isFloatingPoint() || + if (!isa(BI) || BI->getType()->isFloatingPointTy() || isa(BI->getType())) continue; // Floating point ops are not associative. @@ -939,7 +939,7 @@ // is not further optimized, it is likely to be transformed back to a // short-circuited form for code gen, and the source order may have been // optimized for the most likely conditions. - if (BI->getType()->isInteger(1)) + if (BI->getType()->isIntegerTy(1)) continue; // If this is a subtract instruction which is not already in negate form, Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Feb 15 10:12:20 2010 @@ -835,7 +835,7 @@ StoreVal = ConstantInt::get(Context, TotalVal); if (isa(ValTy)) StoreVal = ConstantExpr::getIntToPtr(StoreVal, ValTy); - else if (ValTy->isFloatingPoint()) + else if (ValTy->isFloatingPointTy()) StoreVal = ConstantExpr::getBitCast(StoreVal, ValTy); assert(StoreVal->getType() == ValTy && "Type mismatch!"); @@ -939,7 +939,7 @@ Value *DestField = NewElts[i]; if (EltVal->getType() == FieldTy) { // Storing to an integer field of this size, just do it. - } else if (FieldTy->isFloatingPoint() || isa(FieldTy)) { + } else if (FieldTy->isFloatingPointTy() || isa(FieldTy)) { // Bitcast to the right element type (for fp/vector values). EltVal = new BitCastInst(EltVal, FieldTy, "", SI); } else { @@ -983,7 +983,8 @@ Value *DestField = NewElts[i]; if (EltVal->getType() == ArrayEltTy) { // Storing to an integer field of this size, just do it. - } else if (ArrayEltTy->isFloatingPoint() || isa(ArrayEltTy)) { + } else if (ArrayEltTy->isFloatingPointTy() || + isa(ArrayEltTy)) { // Bitcast to the right element type (for fp/vector values). EltVal = new BitCastInst(EltVal, ArrayEltTy, "", SI); } else { @@ -1043,7 +1044,7 @@ const IntegerType *FieldIntTy = IntegerType::get(LI->getContext(), FieldSizeBits); - if (!isa(FieldTy) && !FieldTy->isFloatingPoint() && + if (!isa(FieldTy) && !FieldTy->isFloatingPointTy() && !isa(FieldTy)) SrcField = new BitCastInst(SrcField, PointerType::getUnqual(FieldIntTy), @@ -1522,7 +1523,7 @@ // If the result is an integer, this is a trunc or bitcast. if (isa(ToType)) { // Should be done. - } else if (ToType->isFloatingPoint() || isa(ToType)) { + } else if (ToType->isFloatingPointTy() || isa(ToType)) { // Just do a bitcast, we know the sizes match up. FromVal = Builder.CreateBitCast(FromVal, ToType, "tmp"); } else { @@ -1600,7 +1601,7 @@ unsigned DestWidth = TD->getTypeSizeInBits(AllocaType); unsigned SrcStoreWidth = TD->getTypeStoreSizeInBits(SV->getType()); unsigned DestStoreWidth = TD->getTypeStoreSizeInBits(AllocaType); - if (SV->getType()->isFloatingPoint() || isa(SV->getType())) + if (SV->getType()->isFloatingPointTy() || isa(SV->getType())) SV = Builder.CreateBitCast(SV, IntegerType::get(SV->getContext(),SrcWidth), "tmp"); else if (isa(SV->getType())) Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Feb 15 10:12:20 2010 @@ -525,7 +525,7 @@ // Must be a Constant Array ConstantArray *Array = dyn_cast(GlobalInit); - if (!Array || !Array->getType()->getElementType()->isInteger(8)) + if (!Array || !Array->getType()->getElementType()->isIntegerTy(8)) return false; // Get the number of elements in the array @@ -697,7 +697,7 @@ if (!TD) return 0; uint64_t Len = GetStringLength(SrcStr); - if (Len == 0 || !FT->getParamType(1)->isInteger(32)) // memchr needs i32. + if (Len == 0 || !FT->getParamType(1)->isIntegerTy(32))// memchr needs i32. return 0; return EmitMemChr(SrcStr, CI->getOperand(2), // include nul. @@ -739,7 +739,7 @@ // Verify the "strcmp" function prototype. const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 2 || - !FT->getReturnType()->isInteger(32) || + !FT->getReturnType()->isIntegerTy(32) || FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != Type::getInt8PtrTy(*Context)) return 0; @@ -787,7 +787,7 @@ // Verify the "strncmp" function prototype. const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || - !FT->getReturnType()->isInteger(32) || + !FT->getReturnType()->isIntegerTy(32) || FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != Type::getInt8PtrTy(*Context) || !isa(FT->getParamType(2))) @@ -1008,7 +1008,7 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || !isa(FT->getParamType(0)) || !isa(FT->getParamType(1)) || - !FT->getReturnType()->isInteger(32)) + !FT->getReturnType()->isIntegerTy(32)) return 0; Value *LHS = CI->getOperand(1), *RHS = CI->getOperand(2); @@ -1241,7 +1241,7 @@ // result type. if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) || FT->getParamType(0) != FT->getParamType(1) || - !FT->getParamType(0)->isFloatingPoint()) + !FT->getParamType(0)->isFloatingPointTy()) return 0; Value *Op1 = CI->getOperand(1), *Op2 = CI->getOperand(2); @@ -1295,7 +1295,7 @@ // Just make sure this has 1 argument of FP type, which matches the // result type. if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) || - !FT->getParamType(0)->isFloatingPoint()) + !FT->getParamType(0)->isFloatingPointTy()) return 0; Value *Op = CI->getOperand(1); @@ -1375,7 +1375,7 @@ // Just make sure this has 2 arguments of the same FP type, which match the // result type. if (FT->getNumParams() != 1 || - !FT->getReturnType()->isInteger(32) || + !FT->getReturnType()->isIntegerTy(32) || !isa(FT->getParamType(0))) return 0; @@ -1411,7 +1411,7 @@ const FunctionType *FT = Callee->getFunctionType(); // We require integer(i32) if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || - !FT->getParamType(0)->isInteger(32)) + !FT->getParamType(0)->isIntegerTy(32)) return 0; // isdigit(c) -> (c-'0') getFunctionType(); // We require integer(i32) if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || - !FT->getParamType(0)->isInteger(32)) + !FT->getParamType(0)->isIntegerTy(32)) return 0; // isascii(c) -> c getFunctionType(); // We require i32(i32) if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) || - !FT->getParamType(0)->isInteger(32)) + !FT->getParamType(0)->isIntegerTy(32)) return 0; // isascii(c) -> c & 0x7f Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Feb 15 10:12:20 2010 @@ -1077,7 +1077,7 @@ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { ConstantInt *CB; if ((CB = dyn_cast(PN->getIncomingValue(i))) && - CB->getType()->isInteger(1)) { + CB->getType()->isIntegerTy(1)) { // Okay, we now know that all edges from PredBB should be revectored to // branch to RealDest. BasicBlock *PredBB = PN->getIncomingBlock(i); Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Feb 15 10:12:20 2010 @@ -431,13 +431,13 @@ // they are used too often to have a single useful name. if (const PointerType *PTy = dyn_cast(Ty)) { const Type *PETy = PTy->getElementType(); - if ((PETy->isPrimitiveType() || PETy->isInteger()) && + if ((PETy->isPrimitiveType() || PETy->isIntegerTy()) && !isa(PETy)) continue; } // Likewise don't insert primitives either. - if (Ty->isInteger() || Ty->isPrimitiveType()) + if (Ty->isIntegerTy() || Ty->isPrimitiveType()) continue; // Get the name as a string and insert it into TypeNames. @@ -849,7 +849,7 @@ static void WriteConstantInt(raw_ostream &Out, const Constant *CV, TypePrinting &TypePrinter, SlotTracker *Machine) { if (const ConstantInt *CI = dyn_cast(CV)) { - if (CI->getType()->isInteger(1)) { + if (CI->getType()->isIntegerTy(1)) { Out << (CI->getZExtValue() ? "true" : "false"); return; } Modified: llvm/trunk/lib/VMCore/Attributes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Attributes.cpp (original) +++ llvm/trunk/lib/VMCore/Attributes.cpp Mon Feb 15 10:12:20 2010 @@ -89,7 +89,7 @@ Attributes Attribute::typeIncompatible(const Type *Ty) { Attributes Incompatible = None; - if (!Ty->isInteger()) + if (!Ty->isIntegerTy()) // Attributes that only apply to integers. Incompatible |= SExt | ZExt; Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Mon Feb 15 10:12:20 2010 @@ -155,12 +155,12 @@ // Handle integral constant input. if (ConstantInt *CI = dyn_cast(V)) { - if (DestTy->isInteger()) + if (DestTy->isIntegerTy()) // Integral -> Integral. This is a no-op because the bit widths must // be the same. Consequently, we just fold to V. return V; - if (DestTy->isFloatingPoint()) + if (DestTy->isFloatingPointTy()) return ConstantFP::get(DestTy->getContext(), APFloat(CI->getValue(), !DestTy->isPPC_FP128Ty())); @@ -364,7 +364,7 @@ // Pointer size doesn't depend on the pointee type, so canonicalize them // to an arbitrary pointee. if (const PointerType *PTy = dyn_cast(Ty)) - if (!PTy->getElementType()->isInteger(1)) + if (!PTy->getElementType()->isIntegerTy(1)) return getFoldedSizeOf(PointerType::get(IntegerType::get(PTy->getContext(), 1), PTy->getAddressSpace()), @@ -429,7 +429,7 @@ // Pointer alignment doesn't depend on the pointee type, so canonicalize them // to an arbitrary pointee. if (const PointerType *PTy = dyn_cast(Ty)) - if (!PTy->getElementType()->isInteger(1)) + if (!PTy->getElementType()->isIntegerTy(1)) return getFoldedAlignOf(PointerType::get(IntegerType::get(PTy->getContext(), 1), @@ -629,7 +629,7 @@ ConstantInt *CI = cast(CE->getOperand(2)); if (CI->isOne() && STy->getNumElements() == 2 && - STy->getElementType(0)->isInteger(1)) { + STy->getElementType(0)->isIntegerTy(1)) { return getFoldedAlignOf(STy->getElementType(1), DestTy, false); } } @@ -1392,7 +1392,7 @@ } // i1 can be simplified in many cases. - if (C1->getType()->isInteger(1)) { + if (C1->getType()->isIntegerTy(1)) { switch (Opcode) { case Instruction::Add: case Instruction::Sub: @@ -1458,10 +1458,10 @@ // Ok, we have two differing integer indices. Sign extend them to be the same // type. Long is always big enough, so we use it. - if (!C1->getType()->isInteger(64)) + if (!C1->getType()->isIntegerTy(64)) C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(C1->getContext())); - if (!C2->getType()->isInteger(64)) + if (!C2->getType()->isIntegerTy(64)) C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(C1->getContext())); if (C1 == C2) return 0; // They are equal @@ -1667,7 +1667,7 @@ // If the cast is not actually changing bits, and the second operand is a // null pointer, do the comparison with the pre-casted value. if (V2->isNullValue() && - (isa(CE1->getType()) || CE1->getType()->isInteger())) { + (isa(CE1->getType()) || CE1->getType()->isIntegerTy())) { if (CE1->getOpcode() == Instruction::ZExt) isSigned = false; if (CE1->getOpcode() == Instruction::SExt) isSigned = true; return evaluateICmpRelation(CE1Op0, @@ -1842,7 +1842,7 @@ } // If the comparison is a comparison between two i1's, simplify it. - if (C1->getType()->isInteger(1)) { + if (C1->getType()->isIntegerTy(1)) { switch(pred) { case ICmpInst::ICMP_EQ: if (isa(C2)) @@ -1931,7 +1931,7 @@ return ConstantVector::get(&ResElts[0], ResElts.size()); } - if (C1->getType()->isFloatingPoint()) { + if (C1->getType()->isFloatingPointTy()) { int Result = -1; // -1 = unknown, 0 = known false, 1 = known true. switch (evaluateFCmpRelation(C1, C2)) { default: llvm_unreachable("Unknown relation!"); @@ -2266,10 +2266,10 @@ // Before adding, extend both operands to i64 to avoid // overflow trouble. - if (!PrevIdx->getType()->isInteger(64)) + if (!PrevIdx->getType()->isIntegerTy(64)) PrevIdx = ConstantExpr::getSExt(PrevIdx, Type::getInt64Ty(Div->getContext())); - if (!Div->getType()->isInteger(64)) + if (!Div->getType()->isIntegerTy(64)) Div = ConstantExpr::getSExt(Div, Type::getInt64Ty(Div->getContext())); Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Feb 15 10:12:20 2010 @@ -404,13 +404,13 @@ Constant* ConstantFP::getZeroValueForNegation(const Type* Ty) { if (const VectorType *PTy = dyn_cast(Ty)) - if (PTy->getElementType()->isFloatingPoint()) { + if (PTy->getElementType()->isFloatingPointTy()) { std::vector zeros(PTy->getNumElements(), getNegativeZero(PTy->getElementType())); return ConstantVector::get(PTy, zeros); } - if (Ty->isFloatingPoint()) + if (Ty->isFloatingPointTy()) return getNegativeZero(Ty); return Constant::getNullValue(Ty); @@ -661,13 +661,13 @@ } Constant* ConstantExpr::getNSWNeg(Constant* C) { - assert(C->getType()->isIntOrIntVector() && + assert(C->getType()->isIntOrIntVectorTy() && "Cannot NEG a nonintegral value!"); return getNSWSub(ConstantFP::getZeroValueForNegation(C->getType()), C); } Constant* ConstantExpr::getNUWNeg(Constant* C) { - assert(C->getType()->isIntOrIntVector() && + assert(C->getType()->isIntOrIntVectorTy() && "Cannot NEG a nonintegral value!"); return getNUWSub(ConstantFP::getZeroValueForNegation(C->getType()), C); } @@ -969,7 +969,7 @@ /// if the elements of the array are all ConstantInt's. bool ConstantArray::isString() const { // Check the element type for i8... - if (!getType()->getElementType()->isInteger(8)) + if (!getType()->getElementType()->isIntegerTy(8)) return false; // Check the elements to make sure they are all integers, not constant // expressions. @@ -984,7 +984,7 @@ /// null bytes except its terminator. bool ConstantArray::isCString() const { // Check the element type for i8... - if (!getType()->getElementType()->isInteger(8)) + if (!getType()->getElementType()->isIntegerTy(8)) return false; // Last element must be a null. @@ -1240,17 +1240,17 @@ Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) { assert(isa(S->getType()) && "Invalid cast"); - assert((Ty->isInteger() || isa(Ty)) && "Invalid cast"); + assert((Ty->isIntegerTy() || isa(Ty)) && "Invalid cast"); - if (Ty->isInteger()) + if (Ty->isIntegerTy()) return getCast(Instruction::PtrToInt, S, Ty); return getCast(Instruction::BitCast, S, Ty); } Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty, bool isSigned) { - assert(C->getType()->isIntOrIntVector() && - Ty->isIntOrIntVector() && "Invalid cast"); + assert(C->getType()->isIntOrIntVectorTy() && + Ty->isIntOrIntVectorTy() && "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); Instruction::CastOps opcode = @@ -1261,7 +1261,7 @@ } Constant *ConstantExpr::getFPCast(Constant *C, const Type *Ty) { - assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && + assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); @@ -1278,8 +1278,8 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVector() && "Trunc operand must be integer"); - assert(Ty->isIntOrIntVector() && "Trunc produces only integral"); + assert(C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer"); + assert(Ty->isIntOrIntVectorTy() && "Trunc produces only integral"); assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "SrcTy must be larger than DestTy for Trunc!"); @@ -1292,8 +1292,8 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVector() && "SExt operand must be integral"); - assert(Ty->isIntOrIntVector() && "SExt produces only integer"); + assert(C->getType()->isIntOrIntVectorTy() && "SExt operand must be integral"); + assert(Ty->isIntOrIntVectorTy() && "SExt produces only integer"); assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for SExt!"); @@ -1306,8 +1306,8 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVector() && "ZEXt operand must be integral"); - assert(Ty->isIntOrIntVector() && "ZExt produces only integer"); + assert(C->getType()->isIntOrIntVectorTy() && "ZEXt operand must be integral"); + assert(Ty->isIntOrIntVectorTy() && "ZExt produces only integer"); assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for ZExt!"); @@ -1320,7 +1320,7 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && + assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "This is an illegal floating point truncation!"); return getFoldedCast(Instruction::FPTrunc, C, Ty); @@ -1332,7 +1332,7 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && + assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "This is an illegal floating point extension!"); return getFoldedCast(Instruction::FPExt, C, Ty); @@ -1344,7 +1344,7 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && + assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && "This is an illegal uint to floating point cast!"); return getFoldedCast(Instruction::UIToFP, C, Ty); } @@ -1355,7 +1355,7 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && + assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && "This is an illegal sint to floating point cast!"); return getFoldedCast(Instruction::SIToFP, C, Ty); } @@ -1366,7 +1366,7 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && + assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && "This is an illegal floating point to uint cast!"); return getFoldedCast(Instruction::FPToUI, C, Ty); } @@ -1377,19 +1377,19 @@ bool toVec = Ty->getTypeID() == Type::VectorTyID; #endif assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && + assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && "This is an illegal floating point to sint cast!"); return getFoldedCast(Instruction::FPToSI, C, Ty); } Constant *ConstantExpr::getPtrToInt(Constant *C, const Type *DstTy) { assert(isa(C->getType()) && "PtrToInt source must be pointer"); - assert(DstTy->isInteger() && "PtrToInt destination must be integral"); + assert(DstTy->isIntegerTy() && "PtrToInt destination must be integral"); return getFoldedCast(Instruction::PtrToInt, C, DstTy); } Constant *ConstantExpr::getIntToPtr(Constant *C, const Type *DstTy) { - assert(C->getType()->isInteger() && "IntToPtr source must be integral"); + assert(C->getType()->isIntegerTy() && "IntToPtr source must be integral"); assert(isa(DstTy) && "IntToPtr destination must be a pointer"); return getFoldedCast(Instruction::IntToPtr, C, DstTy); } @@ -1449,7 +1449,7 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags) { // API compatibility: Adjust integer opcodes to floating-point opcodes. - if (C1->getType()->isFPOrFPVector()) { + if (C1->getType()->isFPOrFPVectorTy()) { if (Opcode == Instruction::Add) Opcode = Instruction::FAdd; else if (Opcode == Instruction::Sub) Opcode = Instruction::FSub; else if (Opcode == Instruction::Mul) Opcode = Instruction::FMul; @@ -1460,51 +1460,51 @@ case Instruction::Sub: case Instruction::Mul: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isIntOrIntVector() && + assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create an integer operation on a non-integer type!"); break; case Instruction::FAdd: case Instruction::FSub: case Instruction::FMul: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isFPOrFPVector() && + assert(C1->getType()->isFPOrFPVectorTy() && "Tried to create a floating-point operation on a " "non-floating-point type!"); break; case Instruction::UDiv: case Instruction::SDiv: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isIntOrIntVector() && + assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::FDiv: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isFPOrFPVector() && + assert(C1->getType()->isFPOrFPVectorTy() && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::URem: case Instruction::SRem: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isIntOrIntVector() && + assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::FRem: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isFPOrFPVector() && + assert(C1->getType()->isFPOrFPVectorTy() && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::And: case Instruction::Or: case Instruction::Xor: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isIntOrIntVector() && + assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create a logical operation on a non-integral type!"); break; case Instruction::Shl: case Instruction::LShr: case Instruction::AShr: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert(C1->getType()->isIntOrIntVector() && + assert(C1->getType()->isIntOrIntVectorTy() && "Tried to create a shift operation on a non-integer type!"); break; default: @@ -1729,7 +1729,7 @@ Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) { assert(isa(Val->getType()) && "Tried to create extractelement operation on non-vector type!"); - assert(Idx->getType()->isInteger(32) && + assert(Idx->getType()->isIntegerTy(32) && "Extractelement index must be i32 type!"); return getExtractElementTy(cast(Val->getType())->getElementType(), Val, Idx); @@ -1755,7 +1755,7 @@ "Tried to create insertelement operation on non-vector type!"); assert(Elt->getType() == cast(Val->getType())->getElementType() && "Insertelement types must match!"); - assert(Idx->getType()->isInteger(32) && + assert(Idx->getType()->isIntegerTy(32) && "Insertelement index must be i32 type!"); return getInsertElementTy(Val->getType(), Val, Elt, Idx); } @@ -1839,9 +1839,9 @@ Constant* ConstantExpr::getNeg(Constant* C) { // API compatibility: Adjust integer opcodes to floating-point opcodes. - if (C->getType()->isFPOrFPVector()) + if (C->getType()->isFPOrFPVectorTy()) return getFNeg(C); - assert(C->getType()->isIntOrIntVector() && + assert(C->getType()->isIntOrIntVectorTy() && "Cannot NEG a nonintegral value!"); return get(Instruction::Sub, ConstantFP::getZeroValueForNegation(C->getType()), @@ -1849,7 +1849,7 @@ } Constant* ConstantExpr::getFNeg(Constant* C) { - assert(C->getType()->isFPOrFPVector() && + assert(C->getType()->isFPOrFPVectorTy() && "Cannot FNEG a non-floating-point value!"); return get(Instruction::FSub, ConstantFP::getZeroValueForNegation(C->getType()), @@ -1857,7 +1857,7 @@ } Constant* ConstantExpr::getNot(Constant* C) { - assert(C->getType()->isIntOrIntVector() && + assert(C->getType()->isIntOrIntVectorTy() && "Cannot NOT a nonintegral value!"); return get(Instruction::Xor, C, Constant::getAllOnesValue(C->getType())); } Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Feb 15 10:12:20 2010 @@ -787,7 +787,7 @@ void BranchInst::AssertOK() { if (isConditional()) - assert(getCondition()->getType()->isInteger(1) && + assert(getCondition()->getType()->isIntegerTy(1) && "May only branch on boolean predicates!"); } @@ -892,7 +892,7 @@ else { assert(!isa(Amt) && "Passed basic block into allocation size parameter! Use other ctor"); - assert(Amt->getType()->isInteger(32) && + assert(Amt->getType()->isIntegerTy(32) && "Allocation array size is not a 32-bit integer!"); } return Amt; @@ -1391,7 +1391,7 @@ bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) { - if (!isa(Val->getType()) || !Index->getType()->isInteger(32)) + if (!isa(Val->getType()) || !Index->getType()->isIntegerTy(32)) return false; return true; } @@ -1438,7 +1438,7 @@ if (Elt->getType() != cast(Vec->getType())->getElementType()) return false;// Second operand of insertelement must be vector element type. - if (!Index->getType()->isInteger(32)) + if (!Index->getType()->isIntegerTy(32)) return false; // Third operand of insertelement must be i32. return true; } @@ -1490,7 +1490,7 @@ const VectorType *MaskTy = dyn_cast(Mask->getType()); if (!isa(Mask) || MaskTy == 0 || - !MaskTy->getElementType()->isInteger(32)) + !MaskTy->getElementType()->isIntegerTy(32)) return false; return true; } @@ -1632,7 +1632,7 @@ static BinaryOperator::BinaryOps AdjustIType(BinaryOperator::BinaryOps iType, const Type *Ty) { // API compatibility: Adjust integer opcodes to floating-point opcodes. - if (Ty->isFPOrFPVector()) { + if (Ty->isFPOrFPVectorTy()) { if (iType == BinaryOperator::Add) iType = BinaryOperator::FAdd; else if (iType == BinaryOperator::Sub) iType = BinaryOperator::FSub; else if (iType == BinaryOperator::Mul) iType = BinaryOperator::FMul; @@ -1678,14 +1678,14 @@ case Mul: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert(getType()->isIntOrIntVector() && + assert(getType()->isIntOrIntVectorTy() && "Tried to create an integer operation on a non-integer type!"); break; case FAdd: case FSub: case FMul: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert(getType()->isFPOrFPVector() && + assert(getType()->isFPOrFPVectorTy() && "Tried to create a floating-point operation on a " "non-floating-point type!"); break; @@ -1693,28 +1693,28 @@ case SDiv: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert((getType()->isInteger() || (isa(getType()) && - cast(getType())->getElementType()->isInteger())) && + assert((getType()->isIntegerTy() || (isa(getType()) && + cast(getType())->getElementType()->isIntegerTy())) && "Incorrect operand type (not integer) for S/UDIV"); break; case FDiv: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert(getType()->isFPOrFPVector() && + assert(getType()->isFPOrFPVectorTy() && "Incorrect operand type (not floating point) for FDIV"); break; case URem: case SRem: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert((getType()->isInteger() || (isa(getType()) && - cast(getType())->getElementType()->isInteger())) && + assert((getType()->isIntegerTy() || (isa(getType()) && + cast(getType())->getElementType()->isIntegerTy())) && "Incorrect operand type (not integer) for S/UREM"); break; case FRem: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert(getType()->isFPOrFPVector() && + assert(getType()->isFPOrFPVectorTy() && "Incorrect operand type (not floating point) for FREM"); break; case Shl: @@ -1722,18 +1722,18 @@ case AShr: assert(getType() == LHS->getType() && "Shift operation should return same type as operands!"); - assert((getType()->isInteger() || + assert((getType()->isIntegerTy() || (isa(getType()) && - cast(getType())->getElementType()->isInteger())) && + cast(getType())->getElementType()->isIntegerTy())) && "Tried to create a shift operation on a non-integral type!"); break; case And: case Or: case Xor: assert(getType() == LHS->getType() && "Logical operation should return same type as operands!"); - assert((getType()->isInteger() || + assert((getType()->isIntegerTy() || (isa(getType()) && - cast(getType())->getElementType()->isInteger())) && + cast(getType())->getElementType()->isIntegerTy())) && "Tried to create a logical operation on a non-integral type!"); break; default: @@ -1960,7 +1960,8 @@ case Instruction::Trunc: return true; case Instruction::BitCast: - return getOperand(0)->getType()->isInteger() && getType()->isInteger(); + return getOperand(0)->getType()->isIntegerTy() && + getType()->isIntegerTy(); } } @@ -2093,25 +2094,25 @@ // no-op cast in second op implies firstOp as long as the DestTy // is integer and we are not converting between a vector and a // non vector type. - if (!isa(SrcTy) && DstTy->isInteger()) + if (!isa(SrcTy) && DstTy->isIntegerTy()) return firstOp; return 0; case 4: // no-op cast in second op implies firstOp as long as the DestTy // is floating point. - if (DstTy->isFloatingPoint()) + if (DstTy->isFloatingPointTy()) return firstOp; return 0; case 5: // no-op cast in first op implies secondOp as long as the SrcTy // is an integer. - if (SrcTy->isInteger()) + if (SrcTy->isIntegerTy()) return secondOp; return 0; case 6: // no-op cast in first op implies secondOp as long as the SrcTy // is a floating point. - if (SrcTy->isFloatingPoint()) + if (SrcTy->isFloatingPointTy()) return secondOp; return 0; case 7: { @@ -2274,10 +2275,10 @@ const Twine &Name, BasicBlock *InsertAtEnd) { assert(isa(S->getType()) && "Invalid cast"); - assert((Ty->isInteger() || isa(Ty)) && + assert((Ty->isIntegerTy() || isa(Ty)) && "Invalid cast"); - if (Ty->isInteger()) + if (Ty->isIntegerTy()) return Create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd); return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); } @@ -2287,10 +2288,10 @@ const Twine &Name, Instruction *InsertBefore) { assert(isa(S->getType()) && "Invalid cast"); - assert((Ty->isInteger() || isa(Ty)) && + assert((Ty->isIntegerTy() || isa(Ty)) && "Invalid cast"); - if (Ty->isInteger()) + if (Ty->isIntegerTy()) return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore); return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); } @@ -2298,7 +2299,7 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty, bool isSigned, const Twine &Name, Instruction *InsertBefore) { - assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() && + assert(C->getType()->isIntOrIntVectorTy() && Ty->isIntOrIntVectorTy() && "Invalid integer cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); @@ -2312,7 +2313,7 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty, bool isSigned, const Twine &Name, BasicBlock *InsertAtEnd) { - assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() && + assert(C->getType()->isIntOrIntVectorTy() && Ty->isIntOrIntVectorTy() && "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); @@ -2326,7 +2327,7 @@ CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, const Twine &Name, Instruction *InsertBefore) { - assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && + assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); @@ -2339,7 +2340,7 @@ CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) { - assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && + assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); @@ -2363,10 +2364,10 @@ unsigned DestBits = DestTy->getScalarSizeInBits(); // 0 for ptr // Run through the possibilities ... - if (DestTy->isInteger()) { // Casting to integral - if (SrcTy->isInteger()) { // Casting from integral + if (DestTy->isIntegerTy()) { // Casting to integral + if (SrcTy->isIntegerTy()) { // Casting from integral return true; - } else if (SrcTy->isFloatingPoint()) { // Casting from floating pt + } else if (SrcTy->isFloatingPointTy()) { // Casting from floating pt return true; } else if (const VectorType *PTy = dyn_cast(SrcTy)) { // Casting from vector @@ -2374,10 +2375,10 @@ } else { // Casting from something else return isa(SrcTy); } - } else if (DestTy->isFloatingPoint()) { // Casting to floating pt - if (SrcTy->isInteger()) { // Casting from integral + } else if (DestTy->isFloatingPointTy()) { // Casting to floating pt + if (SrcTy->isIntegerTy()) { // Casting from integral return true; - } else if (SrcTy->isFloatingPoint()) { // Casting from floating pt + } else if (SrcTy->isFloatingPointTy()) { // Casting from floating pt return true; } else if (const VectorType *PTy = dyn_cast(SrcTy)) { // Casting from vector @@ -2396,7 +2397,7 @@ } else if (isa(DestTy)) { // Casting to pointer if (isa(SrcTy)) { // Casting from pointer return true; - } else if (SrcTy->isInteger()) { // Casting from integral + } else if (SrcTy->isIntegerTy()) { // Casting from integral return true; } else { // Casting from something else return false; @@ -2425,8 +2426,8 @@ "Only first class types are castable!"); // Run through the possibilities ... - if (DestTy->isInteger()) { // Casting to integral - if (SrcTy->isInteger()) { // Casting from integral + if (DestTy->isIntegerTy()) { // Casting to integral + if (SrcTy->isIntegerTy()) { // Casting from integral if (DestBits < SrcBits) return Trunc; // int -> smaller int else if (DestBits > SrcBits) { // its an extension @@ -2437,7 +2438,7 @@ } else { return BitCast; // Same size, No-op cast } - } else if (SrcTy->isFloatingPoint()) { // Casting from floating pt + } else if (SrcTy->isFloatingPointTy()) { // Casting from floating pt if (DestIsSigned) return FPToSI; // FP -> sint else @@ -2452,13 +2453,13 @@ "Casting from a value that is not first-class type"); return PtrToInt; // ptr -> int } - } else if (DestTy->isFloatingPoint()) { // Casting to floating pt - if (SrcTy->isInteger()) { // Casting from integral + } else if (DestTy->isFloatingPointTy()) { // Casting to floating pt + if (SrcTy->isIntegerTy()) { // Casting from integral if (SrcIsSigned) return SIToFP; // sint -> FP else return UIToFP; // uint -> FP - } else if (SrcTy->isFloatingPoint()) { // Casting from floating pt + } else if (SrcTy->isFloatingPointTy()) { // Casting from floating pt if (DestBits < SrcBits) { return FPTrunc; // FP -> smaller FP } else if (DestBits > SrcBits) { @@ -2488,7 +2489,7 @@ } else if (isa(DestTy)) { if (isa(SrcTy)) { return BitCast; // ptr -> ptr - } else if (SrcTy->isInteger()) { + } else if (SrcTy->isIntegerTy()) { return IntToPtr; // int -> ptr } else { assert(!"Casting pointer to other than pointer or int"); @@ -2528,46 +2529,46 @@ switch (op) { default: return false; // This is an input error case Instruction::Trunc: - return SrcTy->isIntOrIntVector() && - DstTy->isIntOrIntVector()&& SrcBitSize > DstBitSize; + return SrcTy->isIntOrIntVectorTy() && + DstTy->isIntOrIntVectorTy()&& SrcBitSize > DstBitSize; case Instruction::ZExt: - return SrcTy->isIntOrIntVector() && - DstTy->isIntOrIntVector()&& SrcBitSize < DstBitSize; + return SrcTy->isIntOrIntVectorTy() && + DstTy->isIntOrIntVectorTy()&& SrcBitSize < DstBitSize; case Instruction::SExt: - return SrcTy->isIntOrIntVector() && - DstTy->isIntOrIntVector()&& SrcBitSize < DstBitSize; + return SrcTy->isIntOrIntVectorTy() && + DstTy->isIntOrIntVectorTy()&& SrcBitSize < DstBitSize; case Instruction::FPTrunc: - return SrcTy->isFPOrFPVector() && - DstTy->isFPOrFPVector() && + return SrcTy->isFPOrFPVectorTy() && + DstTy->isFPOrFPVectorTy() && SrcBitSize > DstBitSize; case Instruction::FPExt: - return SrcTy->isFPOrFPVector() && - DstTy->isFPOrFPVector() && + return SrcTy->isFPOrFPVectorTy() && + DstTy->isFPOrFPVectorTy() && SrcBitSize < DstBitSize; case Instruction::UIToFP: case Instruction::SIToFP: if (const VectorType *SVTy = dyn_cast(SrcTy)) { if (const VectorType *DVTy = dyn_cast(DstTy)) { - return SVTy->getElementType()->isIntOrIntVector() && - DVTy->getElementType()->isFPOrFPVector() && + return SVTy->getElementType()->isIntOrIntVectorTy() && + DVTy->getElementType()->isFPOrFPVectorTy() && SVTy->getNumElements() == DVTy->getNumElements(); } } - return SrcTy->isIntOrIntVector() && DstTy->isFPOrFPVector(); + return SrcTy->isIntOrIntVectorTy() && DstTy->isFPOrFPVectorTy(); case Instruction::FPToUI: case Instruction::FPToSI: if (const VectorType *SVTy = dyn_cast(SrcTy)) { if (const VectorType *DVTy = dyn_cast(DstTy)) { - return SVTy->getElementType()->isFPOrFPVector() && - DVTy->getElementType()->isIntOrIntVector() && + return SVTy->getElementType()->isFPOrFPVectorTy() && + DVTy->getElementType()->isIntOrIntVectorTy() && SVTy->getNumElements() == DVTy->getNumElements(); } } - return SrcTy->isFPOrFPVector() && DstTy->isIntOrIntVector(); + return SrcTy->isFPOrFPVectorTy() && DstTy->isIntOrIntVectorTy(); case Instruction::PtrToInt: - return isa(SrcTy) && DstTy->isInteger(); + return isa(SrcTy) && DstTy->isIntegerTy(); case Instruction::IntToPtr: - return SrcTy->isInteger() && isa(DstTy); + return SrcTy->isIntegerTy() && isa(DstTy); case Instruction::BitCast: // BitCast implies a no-op cast of type only. No bits change. // However, you can't cast pointers to anything but pointers. Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Mon Feb 15 10:12:20 2010 @@ -127,32 +127,32 @@ return this; } -/// isInteger - Return true if this is an IntegerType of the specified width. -bool Type::isInteger(unsigned Bitwidth) const { - return isInteger() && cast(this)->getBitWidth() == Bitwidth; +/// isIntegerTy - Return true if this is an IntegerType of the specified width. +bool Type::isIntegerTy(unsigned Bitwidth) const { + return isIntegerTy() && cast(this)->getBitWidth() == Bitwidth; } -/// isIntOrIntVector - Return true if this is an integer type or a vector of +/// isIntOrIntVectorTy - Return true if this is an integer type or a vector of /// integer types. /// -bool Type::isIntOrIntVector() const { - if (isInteger()) +bool Type::isIntOrIntVectorTy() const { + if (isIntegerTy()) return true; if (ID != Type::VectorTyID) return false; - return cast(this)->getElementType()->isInteger(); + return cast(this)->getElementType()->isIntegerTy(); } -/// isFPOrFPVector - Return true if this is a FP type or a vector of FP types. +/// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP types. /// -bool Type::isFPOrFPVector() const { +bool Type::isFPOrFPVectorTy() const { if (ID == Type::FloatTyID || ID == Type::DoubleTyID || ID == Type::FP128TyID || ID == Type::X86_FP80TyID || ID == Type::PPC_FP128TyID) return true; if (ID != Type::VectorTyID) return false; - return cast(this)->getElementType()->isFloatingPoint(); + return cast(this)->getElementType()->isFloatingPointTy(); } // canLosslesslyBitCastTo - Return true if this type can be converted to @@ -207,7 +207,7 @@ int Type::getFPMantissaWidth() const { if (const VectorType *VTy = dyn_cast(this)) return VTy->getElementType()->getFPMantissaWidth(); - assert(isFloatingPoint() && "Not a floating point type!"); + assert(isFloatingPointTy() && "Not a floating point type!"); if (ID == FloatTyID) return 24; if (ID == DoubleTyID) return 53; if (ID == X86_FP80TyID) return 64; @@ -288,7 +288,7 @@ bool StructType::indexValid(const Value *V) const { // Structure indexes require 32-bit integer constants. - if (V->getType()->isInteger(32)) + if (V->getType()->isIntegerTy(32)) if (const ConstantInt *CU = dyn_cast(V)) return indexValid(CU->getZExtValue()); return false; @@ -314,7 +314,7 @@ bool UnionType::indexValid(const Value *V) const { // Union indexes require 32-bit integer constants. - if (V->getType()->isInteger(32)) + if (V->getType()->isIntegerTy(32)) if (const ConstantInt *CU = dyn_cast(V)) return indexValid(CU->getZExtValue()); return false; @@ -911,7 +911,7 @@ } bool VectorType::isValidElementType(const Type *ElemTy) { - return ElemTy->isInteger() || ElemTy->isFloatingPoint() || + return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() || isa(ElemTy); } @@ -1000,7 +1000,7 @@ bool UnionType::isValidElementType(const Type *ElemTy) { return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() && - !ElemTy->isMetadataTy() && !ElemTy->isFunction(); + !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy(); } int UnionType::getElementTypeIndex(const Type *ElemTy) const { Modified: llvm/trunk/lib/VMCore/ValueTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ValueTypes.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ValueTypes.cpp (original) +++ llvm/trunk/lib/VMCore/ValueTypes.cpp Mon Feb 15 10:12:20 2010 @@ -36,12 +36,12 @@ bool EVT::isExtendedFloatingPoint() const { assert(isExtended() && "Type is not extended!"); - return LLVMTy->isFPOrFPVector(); + return LLVMTy->isFPOrFPVectorTy(); } bool EVT::isExtendedInteger() const { assert(isExtended() && "Type is not extended!"); - return LLVMTy->isIntOrIntVector(); + return LLVMTy->isIntOrIntVectorTy(); } bool EVT::isExtendedVector() const { Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96223&r1=96222&r2=96223&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Feb 15 10:12:20 2010 @@ -821,8 +821,8 @@ unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); unsigned DestBitSize = DestTy->getScalarSizeInBits(); - Assert1(SrcTy->isIntOrIntVector(), "Trunc only operates on integer", &I); - Assert1(DestTy->isIntOrIntVector(), "Trunc only produces integer", &I); + Assert1(SrcTy->isIntOrIntVectorTy(), "Trunc only operates on integer", &I); + Assert1(DestTy->isIntOrIntVectorTy(), "Trunc only produces integer", &I); Assert1(isa(SrcTy) == isa(DestTy), "trunc source and destination must both be a vector or neither", &I); Assert1(SrcBitSize > DestBitSize,"DestTy too big for Trunc", &I); @@ -836,8 +836,8 @@ const Type *DestTy = I.getType(); // Get the size of the types in bits, we'll need this later - Assert1(SrcTy->isIntOrIntVector(), "ZExt only operates on integer", &I); - Assert1(DestTy->isIntOrIntVector(), "ZExt only produces an integer", &I); + Assert1(SrcTy->isIntOrIntVectorTy(), "ZExt only operates on integer", &I); + Assert1(DestTy->isIntOrIntVectorTy(), "ZExt only produces an integer", &I); Assert1(isa(SrcTy) == isa(DestTy), "zext source and destination must both be a vector or neither", &I); unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); @@ -857,8 +857,8 @@ unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); unsigned DestBitSize = DestTy->getScalarSizeInBits(); - Assert1(SrcTy->isIntOrIntVector(), "SExt only operates on integer", &I); - Assert1(DestTy->isIntOrIntVector(), "SExt only produces an integer", &I); + Assert1(SrcTy->isIntOrIntVectorTy(), "SExt only operates on integer", &I); + Assert1(DestTy->isIntOrIntVectorTy(), "SExt only produces an integer", &I); Assert1(isa(SrcTy) == isa(DestTy), "sext source and destination must both be a vector or neither", &I); Assert1(SrcBitSize < DestBitSize,"Type too small for SExt", &I); @@ -874,8 +874,8 @@ unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); unsigned DestBitSize = DestTy->getScalarSizeInBits(); - Assert1(SrcTy->isFPOrFPVector(),"FPTrunc only operates on FP", &I); - Assert1(DestTy->isFPOrFPVector(),"FPTrunc only produces an FP", &I); + Assert1(SrcTy->isFPOrFPVectorTy(),"FPTrunc only operates on FP", &I); + Assert1(DestTy->isFPOrFPVectorTy(),"FPTrunc only produces an FP", &I); Assert1(isa(SrcTy) == isa(DestTy), "fptrunc source and destination must both be a vector or neither",&I); Assert1(SrcBitSize > DestBitSize,"DestTy too big for FPTrunc", &I); @@ -892,8 +892,8 @@ unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); unsigned DestBitSize = DestTy->getScalarSizeInBits(); - Assert1(SrcTy->isFPOrFPVector(),"FPExt only operates on FP", &I); - Assert1(DestTy->isFPOrFPVector(),"FPExt only produces an FP", &I); + Assert1(SrcTy->isFPOrFPVectorTy(),"FPExt only operates on FP", &I); + Assert1(DestTy->isFPOrFPVectorTy(),"FPExt only produces an FP", &I); Assert1(isa(SrcTy) == isa(DestTy), "fpext source and destination must both be a vector or neither", &I); Assert1(SrcBitSize < DestBitSize,"DestTy too small for FPExt", &I); @@ -911,9 +911,9 @@ Assert1(SrcVec == DstVec, "UIToFP source and dest must both be vector or scalar", &I); - Assert1(SrcTy->isIntOrIntVector(), + Assert1(SrcTy->isIntOrIntVectorTy(), "UIToFP source must be integer or integer vector", &I); - Assert1(DestTy->isFPOrFPVector(), + Assert1(DestTy->isFPOrFPVectorTy(), "UIToFP result must be FP or FP vector", &I); if (SrcVec && DstVec) @@ -934,9 +934,9 @@ Assert1(SrcVec == DstVec, "SIToFP source and dest must both be vector or scalar", &I); - Assert1(SrcTy->isIntOrIntVector(), + Assert1(SrcTy->isIntOrIntVectorTy(), "SIToFP source must be integer or integer vector", &I); - Assert1(DestTy->isFPOrFPVector(), + Assert1(DestTy->isFPOrFPVectorTy(), "SIToFP result must be FP or FP vector", &I); if (SrcVec && DstVec) @@ -957,8 +957,9 @@ Assert1(SrcVec == DstVec, "FPToUI source and dest must both be vector or scalar", &I); - Assert1(SrcTy->isFPOrFPVector(), "FPToUI source must be FP or FP vector", &I); - Assert1(DestTy->isIntOrIntVector(), + Assert1(SrcTy->isFPOrFPVectorTy(), "FPToUI source must be FP or FP vector", + &I); + Assert1(DestTy->isIntOrIntVectorTy(), "FPToUI result must be integer or integer vector", &I); if (SrcVec && DstVec) @@ -979,9 +980,9 @@ Assert1(SrcVec == DstVec, "FPToSI source and dest must both be vector or scalar", &I); - Assert1(SrcTy->isFPOrFPVector(), + Assert1(SrcTy->isFPOrFPVectorTy(), "FPToSI source must be FP or FP vector", &I); - Assert1(DestTy->isIntOrIntVector(), + Assert1(DestTy->isIntOrIntVectorTy(), "FPToSI result must be integer or integer vector", &I); if (SrcVec && DstVec) @@ -998,7 +999,7 @@ const Type *DestTy = I.getType(); Assert1(isa(SrcTy), "PtrToInt source must be pointer", &I); - Assert1(DestTy->isInteger(), "PtrToInt result must be integral", &I); + Assert1(DestTy->isIntegerTy(), "PtrToInt result must be integral", &I); visitInstruction(I); } @@ -1008,7 +1009,7 @@ const Type *SrcTy = I.getOperand(0)->getType(); const Type *DestTy = I.getType(); - Assert1(SrcTy->isInteger(), "IntToPtr source must be an integral", &I); + Assert1(SrcTy->isIntegerTy(), "IntToPtr source must be an integral", &I); Assert1(isa(DestTy), "IntToPtr result must be a pointer",&I); visitInstruction(I); @@ -1151,7 +1152,7 @@ case Instruction::UDiv: case Instruction::SRem: case Instruction::URem: - Assert1(B.getType()->isIntOrIntVector(), + Assert1(B.getType()->isIntOrIntVectorTy(), "Integer arithmetic operators only work with integral types!", &B); Assert1(B.getType() == B.getOperand(0)->getType(), "Integer arithmetic operators must have same type " @@ -1164,7 +1165,7 @@ case Instruction::FMul: case Instruction::FDiv: case Instruction::FRem: - Assert1(B.getType()->isFPOrFPVector(), + Assert1(B.getType()->isFPOrFPVectorTy(), "Floating-point arithmetic operators only work with " "floating-point types!", &B); Assert1(B.getType() == B.getOperand(0)->getType(), @@ -1175,7 +1176,7 @@ case Instruction::And: case Instruction::Or: case Instruction::Xor: - Assert1(B.getType()->isIntOrIntVector(), + Assert1(B.getType()->isIntOrIntVectorTy(), "Logical operators only work with integral types!", &B); Assert1(B.getType() == B.getOperand(0)->getType(), "Logical operators must have same type for operands and result!", @@ -1184,7 +1185,7 @@ case Instruction::Shl: case Instruction::LShr: case Instruction::AShr: - Assert1(B.getType()->isIntOrIntVector(), + Assert1(B.getType()->isIntOrIntVectorTy(), "Shifts only work with integral types!", &B); Assert1(B.getType() == B.getOperand(0)->getType(), "Shift return type must be same as operands!", &B); @@ -1203,7 +1204,7 @@ Assert1(Op0Ty == Op1Ty, "Both operands to ICmp instruction are not of the same type!", &IC); // Check that the operands are the right type - Assert1(Op0Ty->isIntOrIntVector() || isa(Op0Ty), + Assert1(Op0Ty->isIntOrIntVectorTy() || isa(Op0Ty), "Invalid operand types for ICmp instruction", &IC); visitInstruction(IC); @@ -1216,7 +1217,7 @@ Assert1(Op0Ty == Op1Ty, "Both operands to FCmp instruction are not of the same type!", &FC); // Check that the operands are the right type - Assert1(Op0Ty->isFPOrFPVector(), + Assert1(Op0Ty->isFPOrFPVectorTy(), "Invalid operand types for FCmp instruction", &FC); visitInstruction(FC); } @@ -1302,7 +1303,7 @@ &AI); Assert1(PTy->getElementType()->isSized(), "Cannot allocate unsized type", &AI); - Assert1(AI.getArraySize()->getType()->isInteger(32), + Assert1(AI.getArraySize()->getType()->isIntegerTy(32), "Alloca array size must be i32", &AI); visitInstruction(AI); } @@ -1734,7 +1735,7 @@ } } } else if (VT == MVT::iAny) { - if (!EltTy->isInteger()) { + if (!EltTy->isIntegerTy()) { CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is not " "an integer type.", F); return false; @@ -1759,7 +1760,7 @@ break; } } else if (VT == MVT::fAny) { - if (!EltTy->isFloatingPoint()) { + if (!EltTy->isFloatingPointTy()) { CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is not " "a floating-point type.", F); return false; From baldrick at free.fr Mon Feb 15 10:24:42 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Feb 2010 16:24:42 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96225 - in /llvm-gcc-4.2/trunk/gcc: config/arm/llvm-arm.cpp config/i386/llvm-i386.cpp config/rs6000/llvm-rs6000.cpp llvm-abi-default.cpp llvm-abi-linux-ppc.cpp llvm-convert.cpp llvm-types.cpp Message-ID: <201002151624.o1FGOgCv004820@zion.cs.uiuc.edu> Author: baldrick Date: Mon Feb 15 10:24:42 2010 New Revision: 96225 URL: http://llvm.org/viewvc/llvm-project?rev=96225&view=rev Log: Uniformize the names of type predicates: rather than having isFloatTy and isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=96225&r1=96224&r2=96225&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Mon Feb 15 10:24:42 2010 @@ -140,7 +140,7 @@ assert(VTy && "expected a vector type"); const Type *ElTy = VTy->getElementType(); if (Val->getType() != ElTy) { - assert(!ElTy->isFloatingPoint() && + assert(!ElTy->isFloatingPointTy() && "only integer types expected to be promoted"); Val = Builder.CreateTrunc(Val, ElTy); } @@ -1652,7 +1652,7 @@ assert(VTy && "expected a vector type for vset_lane vector operand"); const Type *ElTy = VTy->getElementType(); if (Ops[0]->getType() != ElTy) { - assert(!ElTy->isFloatingPoint() && + assert(!ElTy->isFloatingPointTy() && "only integer types expected to be promoted"); Ops[0] = Builder.CreateTrunc(Ops[0], ElTy); } @@ -2560,12 +2560,12 @@ default: assert(0); } - } else if (Ty->isInteger() || isa(Ty) || + } else if (Ty->isIntegerTy() || isa(Ty) || Ty==Type::getVoidTy(Context)) { ; } else { // Floating point scalar argument. - assert(Ty->isFloatingPoint() && Ty->isPrimitiveType() && + assert(Ty->isFloatingPointTy() && Ty->isPrimitiveType() && "Expecting a floating point primitive type!"); switch (Ty->getTypeID()) { Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=96225&r1=96224&r2=96225&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Feb 15 10:24:42 2010 @@ -655,7 +655,7 @@ for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) { const Type *STy = I->get(); - if (!STy->isIntOrIntVector() && !isa(STy)) + if (!STy->isIntOrIntVectorTy() && !isa(STy)) return false; } return true; @@ -687,8 +687,8 @@ // 32 and 64-bit integers are fine, as are float and double. Long double // (which can be picked as the type for a union of 16 bytes) is not fine, // as loads and stores of it get only 10 bytes. - if (EltTy->isInteger(32) || EltTy->isInteger(64) || EltTy->isFloatTy() || - EltTy->isDoubleTy() || isa(EltTy)) { + if (EltTy->isIntegerTy(32) || EltTy->isIntegerTy(64) || + EltTy->isFloatTy() || EltTy->isDoubleTy() || isa(EltTy)) { Elts.push_back(EltTy); continue; } @@ -715,10 +715,10 @@ // makes it ABI compatible for x86-64. Same for _Complex char and _Complex // short in 32-bit. const Type *EltTy = STy->getElementType(0); - return !((TARGET_64BIT && (EltTy->isInteger() || + return !((TARGET_64BIT && (EltTy->isIntegerTy() || EltTy->isFloatTy() || EltTy->isDoubleTy())) || - EltTy->isInteger(16) || EltTy->isInteger(8)); + EltTy->isIntegerTy(16) || EltTy->isIntegerTy(8)); } /* Target hook for llvm-abi.h. It returns true if an aggregate of the @@ -757,14 +757,14 @@ else // All other vector scalar values are passed in XMM registers. ++NumXMMs; - } else if (Ty->isInteger() || isa(Ty)) { + } else if (Ty->isIntegerTy() || isa(Ty)) { ++NumGPRs; } else if (Ty->isVoidTy()) { // Padding bytes that are not passed anywhere ; } else { // Floating point scalar argument. - assert(Ty->isFloatingPoint() && Ty->isPrimitiveType() && + assert(Ty->isFloatingPointTy() && Ty->isPrimitiveType() && "Expecting a floating point primitive type!"); if (Ty->getTypeID() == Type::FloatTyID || Ty->getTypeID() == Type::DoubleTyID) @@ -879,7 +879,7 @@ Ty = STy->getElementType(0); if (const VectorType *VTy = dyn_cast(Ty)) { if (VTy->getNumElements() == 2) { - if (VTy->getElementType()->isInteger()) { + if (VTy->getElementType()->isIntegerTy()) { Elts.push_back(VectorType::get(Type::getInt64Ty(Context), 2)); } else { Elts.push_back(VectorType::get(Type::getDoubleTy(Context), 2)); @@ -887,7 +887,7 @@ Bytes -= 8; } else { assert(VTy->getNumElements() == 4); - if (VTy->getElementType()->isInteger()) { + if (VTy->getElementType()->isIntegerTy()) { Elts.push_back(VectorType::get(Type::getInt32Ty(Context), 4)); } else { Elts.push_back(VectorType::get(Type::getFloatTy(Context), 4)); @@ -1261,14 +1261,14 @@ Ty = STy->getElementType(0); if (const VectorType *VTy = dyn_cast(Ty)) { if (VTy->getNumElements() == 2) { - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isIntegerTy()) Elts.push_back(VectorType::get(Type::getInt64Ty(Context), 2)); else Elts.push_back(VectorType::get(Type::getDoubleTy(Context), 2)); Bytes -= 8; } else { assert(VTy->getNumElements() == 4); - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isIntegerTy()) Elts.push_back(VectorType::get(Type::getInt32Ty(Context), 4)); else Elts.push_back(VectorType::get(Type::getFloatTy(Context), 4)); Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=96225&r1=96224&r2=96225&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Mon Feb 15 10:24:42 2010 @@ -80,9 +80,9 @@ // GetAltivecTypeNumFromType - Given an LLVM type, return a unique ID for // the type in the range 0-3. static int GetAltivecTypeNumFromType(const Type *Ty) { - return (Ty->isInteger(32) ? 0 : \ - (Ty->isInteger(16) ? 1 : \ - (Ty->isInteger(8) ? 2 : \ + return (Ty->isIntegerTy(32) ? 0 : \ + (Ty->isIntegerTy(16) ? 1 : \ + (Ty->isIntegerTy(8) ? 2 : \ ((Ty == Type::getFloatTy(Context)) ? 3 : -1)))); } Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp?rev=96225&r1=96224&r2=96225&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp Mon Feb 15 10:24:42 2010 @@ -318,7 +318,7 @@ if (InSize < Size) { unsigned N = STy->getNumElements(); const llvm::Type *LastEltTy = STy->getElementType(N-1); - if (LastEltTy->isInteger()) + if (LastEltTy->isIntegerTy()) LastEltSizeDiff = getTargetData().getTypeAllocSize(LastEltTy) - (Size - InSize); } Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp?rev=96225&r1=96224&r2=96225&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp Mon Feb 15 10:24:42 2010 @@ -66,7 +66,7 @@ abort(); } else if (isa(Ty)) { NumGPRs++; - } else if (Ty->isInteger()) { + } else if (Ty->isIntegerTy()) { unsigned TypeSize = Ty->getPrimitiveSizeInBits(); unsigned NumRegs = (TypeSize + 31) / 32; @@ -76,7 +76,7 @@ ; } else { // Floating point scalar argument. - assert(Ty->isFloatingPoint() && Ty->isPrimitiveType() && + assert(Ty->isFloatingPointTy() && Ty->isPrimitiveType() && "Expecting a floating point primitive type!"); } } @@ -108,7 +108,7 @@ const Type *Ty = ConvertType(type); const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); if (Ty->isSingleValueType()) { - if (Ty->isInteger()) { + if (Ty->isIntegerTy()) { unsigned TypeSize = Ty->getPrimitiveSizeInBits(); // Determine how many general purpose registers are needed for the @@ -129,7 +129,7 @@ C->HandlePad(Int32Ty); } } - } else if (!(Ty->isFloatingPoint() || + } else if (!(Ty->isFloatingPointTy() || isa(Ty) || isa(Ty))) { abort(); @@ -440,7 +440,7 @@ if (InSize < Size) { unsigned N = STy->getNumElements(); const llvm::Type *LastEltTy = STy->getElementType(N-1); - if (LastEltTy->isInteger()) + if (LastEltTy->isIntegerTy()) LastEltSizeDiff = getTargetData().getTypeAllocSize(LastEltTy) - (Size - InSize); } Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=96225&r1=96224&r2=96225&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Feb 15 10:24:42 2010 @@ -347,7 +347,7 @@ // If this is just a mismatch between integer types, this is due // to K&R prototypes, where the forward proto defines the arg as int // and the actual impls is a short or char. - assert(ArgVal->getType()->isInteger(32) && LLVMTy->isInteger() && + assert(ArgVal->getType()->isIntegerTy(32) && LLVMTy->isIntegerTy() && "Lowerings don't match?"); ArgVal = Builder.CreateTrunc(ArgVal, LLVMTy,NameStack.back().c_str()); } @@ -1254,7 +1254,7 @@ // Handle 'trunc (zext i1 X to T2) to i1' as X, because this occurs all over // the place. if (ZExtInst *CI = dyn_cast(V)) - if (Ty->isInteger(1) && CI->getOperand(0)->getType()->isInteger(1)) + if (Ty->isIntegerTy(1) && CI->getOperand(0)->getType()->isIntegerTy(1)) return CI->getOperand(0); return Builder.CreateCast(Instruction::CastOps(opcode), V, Ty, @@ -1438,14 +1438,14 @@ /// contains any floating point elements. static bool containsFPField(const Type *LLVMTy) { - if (LLVMTy->isFloatingPoint()) + if (LLVMTy->isFloatingPointTy()) return true; const StructType* STy = dyn_cast(LLVMTy); if (STy) { for (StructType::element_iterator I = STy->element_begin(), E = STy->element_end(); I != E; I++) { const Type *Ty = *I; - if (Ty->isFloatingPoint()) + if (Ty->isFloatingPointTy()) return true; if (isa(Ty) && containsFPField(Ty)) return true; @@ -1922,7 +1922,7 @@ if (FPPred == ~0U) { Cond = Emit(exp_cond, 0); // Comparison against zero to convert the result to i1. - if (!Cond->getType()->isInteger(1)) + if (!Cond->getType()->isIntegerTy(1)) Cond = Builder.CreateIsNotNull(Cond, "toBool"); } else { Cond = EmitCompare(exp_cond, UIPred, SIPred, FPPred, Type::getInt1Ty(Context)); @@ -2385,7 +2385,7 @@ // The number of loads needed to read the entire bitfield. unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; - assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); + assert(ValTy->isIntegerTy() && "Invalid bitfield lvalue!"); assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); @@ -3133,7 +3133,7 @@ // The number of stores needed to write the entire bitfield. unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; - assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); + assert(ValTy->isIntegerTy() && "Invalid bitfield lvalue!"); assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); @@ -3330,7 +3330,7 @@ Value *TreeToLLVM::EmitNEGATE_EXPR(tree exp, const MemRef *DestLoc) { if (!DestLoc) { Value *V = Emit(TREE_OPERAND(exp, 0), 0); - if (V->getType()->isFPOrFPVector()) + if (V->getType()->isFPOrFPVectorTy()) return Builder.CreateFNeg(V); if (!isa(V->getType())) { bool HasNSW = !TYPE_OVERFLOW_WRAPS(TREE_TYPE(exp)); @@ -3353,7 +3353,7 @@ // Handle complex numbers: -(a+ib) = -a + i*-b Value *R, *I; EmitLoadFromComplex(R, I, Tmp); - if (R->getType()->isFloatingPoint()) { + if (R->getType()->isFloatingPointTy()) { R = Builder.CreateFNeg(R); I = Builder.CreateFNeg(I); } else { @@ -3375,7 +3375,7 @@ // Handle complex numbers: ~(a+ib) = a + i*-b Value *R, *I; EmitLoadFromComplex(R, I, Tmp); - if (I->getType()->isFloatingPoint()) + if (I->getType()->isFloatingPointTy()) I = Builder.CreateFNeg(I); else I = Builder.CreateNeg(I); @@ -3385,7 +3385,7 @@ Value *TreeToLLVM::EmitABS_EXPR(tree exp) { Value *Op = Emit(TREE_OPERAND(exp, 0), 0); - if (!Op->getType()->isFloatingPoint()) { + if (!Op->getType()->isFloatingPointTy()) { Value *OpN = Builder.CreateNeg(Op, (Op->getNameStr()+"neg").c_str()); ICmpInst::Predicate pred = TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))) ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_SGE; @@ -3435,9 +3435,9 @@ "Expected integer type here"); Ty = ConvertType(TREE_TYPE(exp)); Op = CastToType(Instruction::PtrToInt, Op, Ty); - } else if (Ty->isFloatingPoint() || + } else if (Ty->isFloatingPointTy() || (isa(Ty) && - cast(Ty)->getElementType()->isFloatingPoint())) { + cast(Ty)->getElementType()->isFloatingPointTy())) { Op = BitCastToType(Op, getSuitableBitCastIntType(Ty)); } return BitCastToType(Builder.CreateNot(Op, @@ -3536,9 +3536,9 @@ Opc == Instruction::Xor; const Type *ResTy = Ty; if (isLogicalOp && - (Ty->isFloatingPoint() || + (Ty->isFloatingPointTy() || (isa(Ty) && - cast(Ty)->getElementType()->isFloatingPoint()))) { + cast(Ty)->getElementType()->isFloatingPointTy()))) { Ty = getSuitableBitCastIntType(Ty); LHS = BitCastToType(LHS, Ty); RHS = BitCastToType(RHS, Ty); @@ -3693,7 +3693,7 @@ RHS = CastToType(opcode, RHS, Ty); Value *Compare; - if (LHS->getType()->isFloatingPoint()) + if (LHS->getType()->isFloatingPointTy()) Compare = Builder.CreateFCmp(FCmpInst::Predicate(FPPred), LHS, RHS); else if (TYPE_UNSIGNED(TREE_TYPE(exp))) Compare = Builder.CreateICmp(ICmpInst::Predicate(UIPred), LHS, RHS); @@ -6362,7 +6362,7 @@ Value *Offset = Emit(TREE_VALUE(arglist), 0); Value *Handler = Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0); - Intrinsic::ID IID = IntPtr->isInteger(32) ? + Intrinsic::ID IID = IntPtr->isIntegerTy(32) ? Intrinsic::eh_return_i32 : Intrinsic::eh_return_i64; Offset = Builder.CreateIntCast(Offset, IntPtr, true); @@ -6640,7 +6640,7 @@ switch (TREE_CODE(exp)) { default: TODO(exp); case PLUS_EXPR: // (a+ib) + (c+id) = (a+c) + i(b+d) - if (LHSr->getType()->isFloatingPoint()) { + if (LHSr->getType()->isFloatingPointTy()) { DSTr = Builder.CreateFAdd(LHSr, RHSr, "tmpr"); DSTi = Builder.CreateFAdd(LHSi, RHSi, "tmpi"); } else { @@ -6649,7 +6649,7 @@ } break; case MINUS_EXPR: // (a+ib) - (c+id) = (a-c) + i(b-d) - if (LHSr->getType()->isFloatingPoint()) { + if (LHSr->getType()->isFloatingPointTy()) { DSTr = Builder.CreateFSub(LHSr, RHSr, "tmpr"); DSTi = Builder.CreateFSub(LHSi, RHSi, "tmpi"); } else { @@ -6658,7 +6658,7 @@ } break; case MULT_EXPR: { // (a+ib) * (c+id) = (ac-bd) + i(ad+cb) - if (LHSr->getType()->isFloatingPoint()) { + if (LHSr->getType()->isFloatingPointTy()) { Value *Tmp1 = Builder.CreateFMul(LHSr, RHSr); // a*c Value *Tmp2 = Builder.CreateFMul(LHSi, RHSi); // b*d DSTr = Builder.CreateFSub(Tmp1, Tmp2); // ac-bd @@ -6679,7 +6679,7 @@ } case RDIV_EXPR: { // (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) // RDIV_EXPR should always be floating point. - assert (LHSr->getType()->isFloatingPoint()); + assert (LHSr->getType()->isFloatingPointTy()); Value *Tmp1 = Builder.CreateFMul(LHSr, RHSr); // a*c Value *Tmp2 = Builder.CreateFMul(LHSi, RHSi); // b*d Value *Tmp3 = Builder.CreateFAdd(Tmp1, Tmp2); // ac+bd @@ -6696,7 +6696,7 @@ break; } case EQ_EXPR: // (a+ib) == (c+id) = (a == c) & (b == d) - if (LHSr->getType()->isFloatingPoint()) { + if (LHSr->getType()->isFloatingPointTy()) { DSTr = Builder.CreateFCmpOEQ(LHSr, RHSr, "tmpr"); DSTi = Builder.CreateFCmpOEQ(LHSi, RHSi, "tmpi"); } else { @@ -6705,7 +6705,7 @@ } return Builder.CreateAnd(DSTr, DSTi); case NE_EXPR: // (a+ib) != (c+id) = (a != c) | (b != d) - if (LHSr->getType()->isFloatingPoint()) { + if (LHSr->getType()->isFloatingPointTy()) { DSTr = Builder.CreateFCmpUNE(LHSr, RHSr, "tmpr"); DSTi = Builder.CreateFCmpUNE(LHSi, RHSi, "tmpi"); } else { @@ -7038,7 +7038,7 @@ if (isBitfield(FieldDecl)) { // If this is a bitfield, the declared type must be an integral type. - assert(FieldTy->isInteger() && "Invalid bitfield"); + assert(FieldTy->isIntegerTy() && "Invalid bitfield"); assert(DECL_SIZE(FieldDecl) && TREE_CODE(DECL_SIZE(FieldDecl)) == INTEGER_CST && @@ -7053,7 +7053,7 @@ // things that are difficult to clean up later. This occurs in cases like // "struct X{ unsigned long long x:50; unsigned y:2; }" when accessing y. // We want to access the field as a ulong, not as a uint with an offset. - if (LLVMFieldTy->isInteger() && + if (LLVMFieldTy->isIntegerTy() && LLVMFieldTy->getPrimitiveSizeInBits() >= BitStart + BitfieldSize && LLVMFieldTy->getPrimitiveSizeInBits() == TD.getTypeAllocSizeInBits(LLVMFieldTy)) @@ -7420,7 +7420,7 @@ Constant *TreeConstantToLLVM::ConvertREAL_CST(tree exp) { const Type *Ty = ConvertType(TREE_TYPE(exp)); - assert(Ty->isFloatingPoint() && "Integer REAL_CST?"); + assert(Ty->isFloatingPointTy() && "Integer REAL_CST?"); long RealArr[2]; union { int UArr[2]; @@ -7506,11 +7506,11 @@ unsigned Len = (unsigned)TREE_STRING_LENGTH(exp); std::vector Elts; - if (ElTy->isInteger(8)) { + if (ElTy->isIntegerTy(8)) { const unsigned char *InStr =(const unsigned char *)TREE_STRING_POINTER(exp); for (unsigned i = 0; i != Len; ++i) Elts.push_back(ConstantInt::get(Type::getInt8Ty(Context), InStr[i])); - } else if (ElTy->isInteger(16)) { + } else if (ElTy->isIntegerTy(16)) { assert((Len&1) == 0 && "Length in bytes should be a multiple of element size"); const uint16_t *InStr = @@ -7524,7 +7524,7 @@ else Elts.push_back(ConstantInt::get(Type::getInt16Ty(Context), ByteSwap_16(InStr[i]))); } - } else if (ElTy->isInteger(32)) { + } else if (ElTy->isIntegerTy(32)) { assert((Len&3) == 0 && "Length in bytes should be a multiple of element size"); const uint32_t *InStr = (const uint32_t *)TREE_STRING_POINTER(exp); @@ -7961,7 +7961,7 @@ if (GCCFieldOffsetInBits < NextFieldByteStart*8) { unsigned ValBitSize = ValC->getBitWidth(); assert(!ResultElts.empty() && "Bitfield starts before first element?"); - assert(ResultElts.back()->getType()->isInteger(8) && + assert(ResultElts.back()->getType()->isIntegerTy(8) && isa(ResultElts.back()) && "Merging bitfield with non-bitfield value?"); assert(NextFieldByteStart*8 - GCCFieldOffsetInBits < 8 && Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=96225&r1=96224&r2=96225&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Feb 15 10:24:42 2010 @@ -988,8 +988,8 @@ if (KNRPromotion) { if (type == float_type_node) LLVMTy = ConvertType(double_type_node); - else if (LLVMTy->isInteger(16) || LLVMTy->isInteger(8) || - LLVMTy->isInteger(1)) + else if (LLVMTy->isIntegerTy(16) || LLVMTy->isIntegerTy(8) || + LLVMTy->isIntegerTy(1)) LLVMTy = Type::getInt32Ty(Context); } ArgTypes.push_back(LLVMTy); @@ -1391,13 +1391,13 @@ const Type *LastType = Elements.back(); unsigned PadBytes = 0; - if (LastType->isInteger(8)) + if (LastType->isIntegerTy(8)) PadBytes = 1 - NoOfBytesToRemove; - else if (LastType->isInteger(16)) + else if (LastType->isIntegerTy(16)) PadBytes = 2 - NoOfBytesToRemove; - else if (LastType->isInteger(32)) + else if (LastType->isIntegerTy(32)) PadBytes = 4 - NoOfBytesToRemove; - else if (LastType->isInteger(64)) + else if (LastType->isIntegerTy(64)) PadBytes = 8 - NoOfBytesToRemove; else return; From greened at obbligato.org Mon Feb 15 10:48:31 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:48:31 -0000 Subject: [llvm-commits] [llvm] r96226 - in /llvm/trunk: include/llvm/CodeGen/MachineMemOperand.h lib/CodeGen/MachineInstr.cpp Message-ID: <201002151648.o1FGmVvL006149@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:48:31 2010 New Revision: 96226 URL: http://llvm.org/viewvc/llvm-project?rev=96226&view=rev Log: Add non-temporal flags to MachineMemOperand. Modified: llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h?rev=96226&r1=96225&r2=96226&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h Mon Feb 15 10:48:31 2010 @@ -46,7 +46,11 @@ /// The memory access writes data. MOStore = 2, /// The memory access is volatile. - MOVolatile = 4 + MOVolatile = 4, + /// The memory access is non-temporal. + MONonTemporal = 8, + // This is the number of bits we need to represent flags. + MOMaxBits = 4 }; /// MachineMemOperand - Construct an MachineMemOperand object with the @@ -64,7 +68,7 @@ const Value *getValue() const { return V; } /// getFlags - Return the raw flags of the source value, \see MemOperandFlags. - unsigned int getFlags() const { return Flags & 7; } + unsigned int getFlags() const { return Flags & ((1 << MOMaxBits) - 1); } /// getOffset - For normal values, this is a byte offset added to the base /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex @@ -80,11 +84,12 @@ /// getBaseAlignment - Return the minimum known alignment in bytes of the /// base address, without the offset. - uint64_t getBaseAlignment() const { return (1u << (Flags >> 3)) >> 1; } + uint64_t getBaseAlignment() const { return (1u << (Flags >> MOMaxBits)) >> 1; } bool isLoad() const { return Flags & MOLoad; } bool isStore() const { return Flags & MOStore; } bool isVolatile() const { return Flags & MOVolatile; } + bool isNonTemporal() const { return Flags & MONonTemporal; } /// refineAlignment - Update this MachineMemOperand to reflect the alignment /// of MMO, if it has a greater alignment. This must only be used when the Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=96226&r1=96225&r2=96226&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Feb 15 10:48:31 2010 @@ -305,7 +305,7 @@ MachineMemOperand::MachineMemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s, unsigned int a) : Offset(o), Size(s), V(v), - Flags((f & 7) | ((Log2_32(a) + 1) << 3)) { + Flags((f & ((1 << MOMaxBits) - 1)) | ((Log2_32(a) + 1) << MOMaxBits)) { assert(getBaseAlignment() == a && "Alignment is not a power of 2!"); assert((isLoad() || isStore()) && "Not a load/store!"); } @@ -327,7 +327,8 @@ if (MMO->getBaseAlignment() >= getBaseAlignment()) { // Update the alignment value. - Flags = (Flags & 7) | ((Log2_32(MMO->getBaseAlignment()) + 1) << 3); + Flags = (Flags & ((1 << MOMaxBits) - 1)) | + ((Log2_32(MMO->getBaseAlignment()) + 1) << MOMaxBits); // Also update the base and offset, because the new alignment may // not be applicable with the old ones. V = MMO->getValue(); From greened at obbligato.org Mon Feb 15 10:49:52 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:49:52 -0000 Subject: [llvm-commits] [llvm] r96227 - /llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Message-ID: <201002151649.o1FGnqHo006306@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:49:52 2010 New Revision: 96227 URL: http://llvm.org/viewvc/llvm-project?rev=96227&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=96227&r1=96226&r2=96227&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Mon Feb 15 10:49:52 2010 @@ -390,7 +390,12 @@ if (Offset % 4 == 0) { // We've managed to infer better alignment information than the load // already has. Use an aligned load. - return DAG.getLoad(getPointerTy(), dl, Chain, BasePtr, NULL, 4); + // + // FIXME: No new alignment information is actually passed here. + // Should the offset really be 4? + // + return DAG.getLoad(getPointerTy(), dl, Chain, BasePtr, NULL, 4, + false, false, 0); } // Lower to // ldw low, base[offset >> 2] @@ -407,9 +412,9 @@ SDValue HighAddr = DAG.getNode(ISD::ADD, dl, MVT::i32, Base, HighOffset); SDValue Low = DAG.getLoad(getPointerTy(), dl, Chain, - LowAddr, NULL, 4); + LowAddr, NULL, 4, false, false, 0); SDValue High = DAG.getLoad(getPointerTy(), dl, Chain, - HighAddr, NULL, 4); + HighAddr, NULL, 4, false, false, 0); SDValue LowShifted = DAG.getNode(ISD::SRL, dl, MVT::i32, Low, LowShift); SDValue HighShifted = DAG.getNode(ISD::SHL, dl, MVT::i32, High, HighShift); SDValue Result = DAG.getNode(ISD::OR, dl, MVT::i32, LowShifted, HighShifted); @@ -423,12 +428,13 @@ int SVOffset = LD->getSrcValueOffset(); SDValue Low = DAG.getExtLoad(ISD::ZEXTLOAD, dl, MVT::i32, Chain, BasePtr, LD->getSrcValue(), SVOffset, MVT::i16, - LD->isVolatile(), 2); + LD->isVolatile(), LD->isNonTemporal(), 2); SDValue HighAddr = DAG.getNode(ISD::ADD, dl, MVT::i32, BasePtr, DAG.getConstant(2, MVT::i32)); SDValue High = DAG.getExtLoad(ISD::EXTLOAD, dl, MVT::i32, Chain, HighAddr, LD->getSrcValue(), SVOffset + 2, - MVT::i16, LD->isVolatile(), 2); + MVT::i16, LD->isVolatile(), + LD->isNonTemporal(), 2); SDValue HighShifted = DAG.getNode(ISD::SHL, dl, MVT::i32, High, DAG.getConstant(16, MVT::i32)); SDValue Result = DAG.getNode(ISD::OR, dl, MVT::i32, Low, HighShifted); @@ -487,12 +493,14 @@ DAG.getConstant(16, MVT::i32)); SDValue StoreLow = DAG.getTruncStore(Chain, dl, Low, BasePtr, ST->getSrcValue(), SVOffset, MVT::i16, - ST->isVolatile(), 2); + ST->isVolatile(), ST->isNonTemporal(), + 2); SDValue HighAddr = DAG.getNode(ISD::ADD, dl, MVT::i32, BasePtr, DAG.getConstant(2, MVT::i32)); SDValue StoreHigh = DAG.getTruncStore(Chain, dl, High, HighAddr, ST->getSrcValue(), SVOffset + 2, - MVT::i16, ST->isVolatile(), 2); + MVT::i16, ST->isVolatile(), + ST->isNonTemporal(), 2); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, StoreLow, StoreHigh); } @@ -561,15 +569,16 @@ const Value *V = cast(Node->getOperand(2))->getValue(); EVT VT = Node->getValueType(0); SDValue VAList = DAG.getLoad(getPointerTy(), dl, Node->getOperand(0), - Node->getOperand(1), V, 0); + Node->getOperand(1), V, 0, false, false, 0); // Increment the pointer, VAList, to the next vararg SDValue Tmp3 = DAG.getNode(ISD::ADD, dl, getPointerTy(), VAList, DAG.getConstant(VT.getSizeInBits(), getPointerTy())); // Store the incremented VAList to the legalized pointer - Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Node->getOperand(1), V, 0); + Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Node->getOperand(1), V, 0, + false, false, 0); // Load the actual argument out of the pointer VAList - return DAG.getLoad(VT, dl, Tmp3, VAList, NULL, 0); + return DAG.getLoad(VT, dl, Tmp3, VAList, NULL, 0, false, false, 0); } SDValue XCoreTargetLowering:: @@ -582,7 +591,8 @@ XCoreFunctionInfo *XFI = MF.getInfo(); SDValue Addr = DAG.getFrameIndex(XFI->getVarArgsFrameIndex(), MVT::i32); const Value *SV = cast(Op.getOperand(2))->getValue(); - return DAG.getStore(Op.getOperand(0), dl, Addr, Op.getOperand(1), SV, 0); + return DAG.getStore(Op.getOperand(0), dl, Addr, Op.getOperand(1), SV, 0, + false, false, 0); } SDValue XCoreTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) { @@ -877,7 +887,8 @@ // Create the SelectionDAG nodes corresponding to a load //from this parameter SDValue FIN = DAG.getFrameIndex(FI, MVT::i32); - InVals.push_back(DAG.getLoad(VA.getLocVT(), dl, Chain, FIN, NULL, 0)); + InVals.push_back(DAG.getLoad(VA.getLocVT(), dl, Chain, FIN, NULL, 0, + false, false, 0)); } } @@ -908,7 +919,8 @@ RegInfo.addLiveIn(ArgRegs[i], VReg); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i32); // Move argument from virt reg -> stack - SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0); + SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0, + false, false, 0); MemOps.push_back(Store); } if (!MemOps.empty()) From greened at obbligato.org Mon Feb 15 10:53:33 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:53:33 -0000 Subject: [llvm-commits] [llvm] r96228 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <201002151653.o1FGrXlB006548@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:53:33 2010 New Revision: 96228 URL: http://llvm.org/viewvc/llvm-project?rev=96228&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=96228&r1=96227&r2=96228&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb 15 10:53:33 2010 @@ -1451,7 +1451,8 @@ VA.getLocMemOffset(), isImmutable, false); SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); return DAG.getLoad(ValVT, dl, Chain, FIN, - PseudoSourceValue::getFixedStack(FI), 0); + PseudoSourceValue::getFixedStack(FI), 0, + false, false, 0); } } @@ -1545,7 +1546,8 @@ // If value is passed via pointer - do a load. if (VA.getLocInfo() == CCValAssign::Indirect) - ArgValue = DAG.getLoad(VA.getValVT(), dl, Chain, ArgValue, NULL, 0); + ArgValue = DAG.getLoad(VA.getValVT(), dl, Chain, ArgValue, NULL, 0, + false, false, 0); InVals.push_back(ArgValue); } @@ -1640,7 +1642,7 @@ SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, PseudoSourceValue::getFixedStack(RegSaveFrameIndex), - Offset); + Offset, false, false, 0); MemOps.push_back(Store); Offset += 8; } @@ -1709,7 +1711,8 @@ return CreateCopyOfByValArgument(Arg, PtrOff, Chain, Flags, DAG, dl); } return DAG.getStore(Chain, dl, Arg, PtrOff, - PseudoSourceValue::getStack(), LocMemOffset); + PseudoSourceValue::getStack(), LocMemOffset, + false, false, 0); } /// EmitTailCallLoadRetAddr - Emit a load of return address if tail call @@ -1724,7 +1727,7 @@ OutRetAddr = getReturnAddressFrameIndex(DAG); // Load the "old" Return address. - OutRetAddr = DAG.getLoad(VT, dl, Chain, OutRetAddr, NULL, 0); + OutRetAddr = DAG.getLoad(VT, dl, Chain, OutRetAddr, NULL, 0, false, false, 0); return SDValue(OutRetAddr.getNode(), 1); } @@ -1743,7 +1746,8 @@ EVT VT = Is64Bit ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT); Chain = DAG.getStore(Chain, dl, RetAddrFrIdx, NewRetAddrFrIdx, - PseudoSourceValue::getFixedStack(NewReturnAddrFI), 0); + PseudoSourceValue::getFixedStack(NewReturnAddrFI), 0, + false, false, 0); return Chain; } @@ -1854,7 +1858,8 @@ SDValue SpillSlot = DAG.CreateStackTemporary(VA.getValVT()); int FI = cast(SpillSlot)->getIndex(); Chain = DAG.getStore(Chain, dl, Arg, SpillSlot, - PseudoSourceValue::getFixedStack(FI), 0); + PseudoSourceValue::getFixedStack(FI), 0, + false, false, 0); Arg = SpillSlot; break; } @@ -1985,7 +1990,8 @@ // Store relative to framepointer. MemOpChains2.push_back( DAG.getStore(ArgChain, dl, Arg, FIN, - PseudoSourceValue::getFixedStack(FI), 0)); + PseudoSourceValue::getFixedStack(FI), 0, + false, false, 0)); } } } @@ -3564,7 +3570,8 @@ int EltNo = (Offset - StartOffset) >> 2; int Mask[4] = { EltNo, EltNo, EltNo, EltNo }; EVT VT = (PVT == MVT::i32) ? MVT::v4i32 : MVT::v4f32; - SDValue V1 = DAG.getLoad(VT, dl, Chain, Ptr,LD->getSrcValue(),0); + SDValue V1 = DAG.getLoad(VT, dl, Chain, Ptr,LD->getSrcValue(),0, + false, false, 0); // Canonicalize it to a v4i32 shuffle. V1 = DAG.getNode(ISD::BIT_CONVERT, dl, MVT::v4i32, V1); return DAG.getNode(ISD::BIT_CONVERT, dl, VT, @@ -5063,7 +5070,7 @@ // load. if (isGlobalStubReference(OpFlags)) Result = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), Result, - PseudoSourceValue::getGOT(), 0); + PseudoSourceValue::getGOT(), 0, false, false, 0); // If there was a non-zero offset that we didn't fold, create an explicit // addition for it. @@ -5143,7 +5150,7 @@ MVT::i32)); SDValue ThreadPointer = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Base, - NULL, 0); + NULL, 0, false, false, 0); unsigned char OperandFlags = 0; // Most TLS accesses are not RIP relative, even on x86-64. One exception is @@ -5168,7 +5175,7 @@ if (model == TLSModel::InitialExec) Offset = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Offset, - PseudoSourceValue::getGOT(), 0); + PseudoSourceValue::getGOT(), 0, false, false, 0); // The address of the thread local variable is the add of the thread // pointer with the offset of the variable. @@ -5285,7 +5292,8 @@ SDValue StackSlot = DAG.getFrameIndex(SSFI, getPointerTy()); SDValue Chain = DAG.getStore(DAG.getEntryNode(), dl, Op.getOperand(0), StackSlot, - PseudoSourceValue::getFixedStack(SSFI), 0); + PseudoSourceValue::getFixedStack(SSFI), 0, + false, false, 0); return BuildFILD(Op, SrcVT, Chain, StackSlot, DAG); } @@ -5320,7 +5328,8 @@ }; Chain = DAG.getNode(X86ISD::FST, dl, Tys, Ops, array_lengthof(Ops)); Result = DAG.getLoad(Op.getValueType(), dl, Chain, StackSlot, - PseudoSourceValue::getFixedStack(SSFI), 0); + PseudoSourceValue::getFixedStack(SSFI), 0, + false, false, 0); } return Result; @@ -5393,12 +5402,12 @@ SDValue Unpck1 = getUnpackl(DAG, dl, MVT::v4i32, XR1, XR2); SDValue CLod0 = DAG.getLoad(MVT::v4i32, dl, DAG.getEntryNode(), CPIdx0, PseudoSourceValue::getConstantPool(), 0, - false, 16); + false, false, 16); SDValue Unpck2 = getUnpackl(DAG, dl, MVT::v4i32, Unpck1, CLod0); SDValue XR2F = DAG.getNode(ISD::BIT_CONVERT, dl, MVT::v2f64, Unpck2); SDValue CLod1 = DAG.getLoad(MVT::v2f64, dl, CLod0.getValue(1), CPIdx1, PseudoSourceValue::getConstantPool(), 0, - false, 16); + false, false, 16); SDValue Sub = DAG.getNode(ISD::FSUB, dl, MVT::v2f64, XR2F, CLod1); // Add the halves; easiest way is to swap them into another reg first. @@ -5485,9 +5494,9 @@ SDValue OffsetSlot = DAG.getNode(ISD::ADD, dl, getPointerTy(), StackSlot, WordOff); SDValue Store1 = DAG.getStore(DAG.getEntryNode(), dl, Op.getOperand(0), - StackSlot, NULL, 0); + StackSlot, NULL, 0, false, false, 0); SDValue Store2 = DAG.getStore(Store1, dl, DAG.getConstant(0, MVT::i32), - OffsetSlot, NULL, 0); + OffsetSlot, NULL, 0, false, false, 0); return BuildFILD(Op, MVT::i64, Store2, StackSlot, DAG); } @@ -5535,7 +5544,8 @@ if (isScalarFPTypeInSSEReg(Op.getOperand(0).getValueType())) { assert(DstTy == MVT::i64 && "Invalid FP_TO_SINT to lower!"); Chain = DAG.getStore(Chain, dl, Value, StackSlot, - PseudoSourceValue::getFixedStack(SSFI), 0); + PseudoSourceValue::getFixedStack(SSFI), 0, + false, false, 0); SDVTList Tys = DAG.getVTList(Op.getOperand(0).getValueType(), MVT::Other); SDValue Ops[] = { Chain, StackSlot, DAG.getValueType(Op.getOperand(0).getValueType()) @@ -5569,7 +5579,7 @@ // Load the result. return DAG.getLoad(Op.getValueType(), Op.getDebugLoc(), - FIST, StackSlot, NULL, 0); + FIST, StackSlot, NULL, 0, false, false, 0); } SDValue X86TargetLowering::LowerFP_TO_UINT(SDValue Op, SelectionDAG &DAG) { @@ -5579,7 +5589,7 @@ // Load the result. return DAG.getLoad(Op.getValueType(), Op.getDebugLoc(), - FIST, StackSlot, NULL, 0); + FIST, StackSlot, NULL, 0, false, false, 0); } SDValue X86TargetLowering::LowerFABS(SDValue Op, SelectionDAG &DAG) { @@ -5604,8 +5614,8 @@ Constant *C = ConstantVector::get(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, - PseudoSourceValue::getConstantPool(), 0, - false, 16); + PseudoSourceValue::getConstantPool(), 0, + false, false, 16); return DAG.getNode(X86ISD::FAND, dl, VT, Op.getOperand(0), Mask); } @@ -5631,8 +5641,8 @@ Constant *C = ConstantVector::get(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, - PseudoSourceValue::getConstantPool(), 0, - false, 16); + PseudoSourceValue::getConstantPool(), 0, + false, false, 16); if (VT.isVector()) { return DAG.getNode(ISD::BIT_CONVERT, dl, VT, DAG.getNode(ISD::XOR, dl, MVT::v2i64, @@ -5680,8 +5690,8 @@ Constant *C = ConstantVector::get(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask1 = DAG.getLoad(SrcVT, dl, DAG.getEntryNode(), CPIdx, - PseudoSourceValue::getConstantPool(), 0, - false, 16); + PseudoSourceValue::getConstantPool(), 0, + false, false, 16); SDValue SignBit = DAG.getNode(X86ISD::FAND, dl, SrcVT, Op1, Mask1); // Shift sign bit right or left if the two operands have different types. @@ -5709,8 +5719,8 @@ C = ConstantVector::get(CV); CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask2 = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, - PseudoSourceValue::getConstantPool(), 0, - false, 16); + PseudoSourceValue::getConstantPool(), 0, + false, false, 16); SDValue Val = DAG.getNode(X86ISD::FAND, dl, VT, Op0, Mask2); // Or the value with the sign bit. @@ -6618,7 +6628,8 @@ // vastart just stores the address of the VarArgsFrameIndex slot into the // memory location argument. SDValue FR = DAG.getFrameIndex(VarArgsFrameIndex, getPointerTy()); - return DAG.getStore(Op.getOperand(0), dl, FR, Op.getOperand(1), SV, 0); + return DAG.getStore(Op.getOperand(0), dl, FR, Op.getOperand(1), SV, 0, + false, false, 0); } // __va_list_tag: @@ -6630,8 +6641,8 @@ SDValue FIN = Op.getOperand(1); // Store gp_offset SDValue Store = DAG.getStore(Op.getOperand(0), dl, - DAG.getConstant(VarArgsGPOffset, MVT::i32), - FIN, SV, 0); + DAG.getConstant(VarArgsGPOffset, MVT::i32), + FIN, SV, 0, false, false, 0); MemOps.push_back(Store); // Store fp_offset @@ -6639,21 +6650,23 @@ FIN, DAG.getIntPtrConstant(4)); Store = DAG.getStore(Op.getOperand(0), dl, DAG.getConstant(VarArgsFPOffset, MVT::i32), - FIN, SV, 0); + FIN, SV, 0, false, false, 0); MemOps.push_back(Store); // Store ptr to overflow_arg_area FIN = DAG.getNode(ISD::ADD, dl, getPointerTy(), FIN, DAG.getIntPtrConstant(4)); SDValue OVFIN = DAG.getFrameIndex(VarArgsFrameIndex, getPointerTy()); - Store = DAG.getStore(Op.getOperand(0), dl, OVFIN, FIN, SV, 0); + Store = DAG.getStore(Op.getOperand(0), dl, OVFIN, FIN, SV, 0, + false, false, 0); MemOps.push_back(Store); // Store ptr to reg_save_area. FIN = DAG.getNode(ISD::ADD, dl, getPointerTy(), FIN, DAG.getIntPtrConstant(8)); SDValue RSFIN = DAG.getFrameIndex(RegSaveFrameIndex, getPointerTy()); - Store = DAG.getStore(Op.getOperand(0), dl, RSFIN, FIN, SV, 0); + Store = DAG.getStore(Op.getOperand(0), dl, RSFIN, FIN, SV, 0, + false, false, 0); MemOps.push_back(Store); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &MemOps[0], MemOps.size()); @@ -6939,13 +6952,13 @@ return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), DAG.getNode(ISD::ADD, dl, getPointerTy(), FrameAddr, Offset), - NULL, 0); + NULL, 0, false, false, 0); } // Just load the return address. SDValue RetAddrFI = getReturnAddressFrameIndex(DAG); return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), - RetAddrFI, NULL, 0); + RetAddrFI, NULL, 0, false, false, 0); } SDValue X86TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) { @@ -6957,7 +6970,8 @@ unsigned FrameReg = Subtarget->is64Bit() ? X86::RBP : X86::EBP; SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), dl, FrameReg, VT); while (Depth--) - FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr, NULL, 0); + FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr, NULL, 0, + false, false, 0); return FrameAddr; } @@ -6981,7 +6995,7 @@ SDValue StoreAddr = DAG.getNode(ISD::SUB, dl, getPointerTy(), Frame, DAG.getIntPtrConstant(-TD->getPointerSize())); StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), StoreAddr, Offset); - Chain = DAG.getStore(Chain, dl, Handler, StoreAddr, NULL, 0); + Chain = DAG.getStore(Chain, dl, Handler, StoreAddr, NULL, 0, false, false, 0); Chain = DAG.getCopyToReg(Chain, dl, StoreAddrReg, StoreAddr); MF.getRegInfo().addLiveOut(StoreAddrReg); @@ -7016,11 +7030,12 @@ unsigned OpCode = ((MOV64ri | N86R11) << 8) | REX_WB; // movabsq r11 SDValue Addr = Trmp; OutChains[0] = DAG.getStore(Root, dl, DAG.getConstant(OpCode, MVT::i16), - Addr, TrmpAddr, 0); + Addr, TrmpAddr, 0, false, false, 0); Addr = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp, DAG.getConstant(2, MVT::i64)); - OutChains[1] = DAG.getStore(Root, dl, FPtr, Addr, TrmpAddr, 2, false, 2); + OutChains[1] = DAG.getStore(Root, dl, FPtr, Addr, TrmpAddr, 2, + false, false, 2); // Load the 'nest' parameter value into R10. // R10 is specified in X86CallingConv.td @@ -7028,24 +7043,25 @@ Addr = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp, DAG.getConstant(10, MVT::i64)); OutChains[2] = DAG.getStore(Root, dl, DAG.getConstant(OpCode, MVT::i16), - Addr, TrmpAddr, 10); + Addr, TrmpAddr, 10, false, false, 0); Addr = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp, DAG.getConstant(12, MVT::i64)); - OutChains[3] = DAG.getStore(Root, dl, Nest, Addr, TrmpAddr, 12, false, 2); + OutChains[3] = DAG.getStore(Root, dl, Nest, Addr, TrmpAddr, 12, + false, false, 2); // Jump to the nested function. OpCode = (JMP64r << 8) | REX_WB; // jmpq *... Addr = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp, DAG.getConstant(20, MVT::i64)); OutChains[4] = DAG.getStore(Root, dl, DAG.getConstant(OpCode, MVT::i16), - Addr, TrmpAddr, 20); + Addr, TrmpAddr, 20, false, false, 0); unsigned char ModRM = N86R11 | (4 << 3) | (3 << 6); // ...r11 Addr = DAG.getNode(ISD::ADD, dl, MVT::i64, Trmp, DAG.getConstant(22, MVT::i64)); OutChains[5] = DAG.getStore(Root, dl, DAG.getConstant(ModRM, MVT::i8), Addr, - TrmpAddr, 22); + TrmpAddr, 22, false, false, 0); SDValue Ops[] = { Trmp, DAG.getNode(ISD::TokenFactor, dl, MVT::Other, OutChains, 6) }; @@ -7105,21 +7121,23 @@ const unsigned char N86Reg = RegInfo->getX86RegNum(NestReg); OutChains[0] = DAG.getStore(Root, dl, DAG.getConstant(MOV32ri|N86Reg, MVT::i8), - Trmp, TrmpAddr, 0); + Trmp, TrmpAddr, 0, false, false, 0); Addr = DAG.getNode(ISD::ADD, dl, MVT::i32, Trmp, DAG.getConstant(1, MVT::i32)); - OutChains[1] = DAG.getStore(Root, dl, Nest, Addr, TrmpAddr, 1, false, 1); + OutChains[1] = DAG.getStore(Root, dl, Nest, Addr, TrmpAddr, 1, + false, false, 1); const unsigned char JMP = 0xE9; // jmp <32bit dst> opcode. Addr = DAG.getNode(ISD::ADD, dl, MVT::i32, Trmp, DAG.getConstant(5, MVT::i32)); OutChains[2] = DAG.getStore(Root, dl, DAG.getConstant(JMP, MVT::i8), Addr, - TrmpAddr, 5, false, 1); + TrmpAddr, 5, false, false, 1); Addr = DAG.getNode(ISD::ADD, dl, MVT::i32, Trmp, DAG.getConstant(6, MVT::i32)); - OutChains[3] = DAG.getStore(Root, dl, Disp, Addr, TrmpAddr, 6, false, 1); + OutChains[3] = DAG.getStore(Root, dl, Disp, Addr, TrmpAddr, 6, + false, false, 1); SDValue Ops[] = { Trmp, DAG.getNode(ISD::TokenFactor, dl, MVT::Other, OutChains, 4) }; @@ -7162,7 +7180,8 @@ DAG.getEntryNode(), StackSlot); // Load FP Control Word from stack slot - SDValue CWD = DAG.getLoad(MVT::i16, dl, Chain, StackSlot, NULL, 0); + SDValue CWD = DAG.getLoad(MVT::i16, dl, Chain, StackSlot, NULL, 0, + false, false, 0); // Transform as necessary SDValue CWD1 = @@ -7526,7 +7545,8 @@ if (FIST.getNode() != 0) { EVT VT = N->getValueType(0); // Return a load from the stack slot. - Results.push_back(DAG.getLoad(VT, dl, FIST, StackSlot, NULL, 0)); + Results.push_back(DAG.getLoad(VT, dl, FIST, StackSlot, NULL, 0, + false, false, 0)); } return; } @@ -8747,10 +8767,11 @@ if (DAG.InferPtrAlignment(LD->getBasePtr()) >= 16) return DAG.getLoad(VT, dl, LD->getChain(), LD->getBasePtr(), LD->getSrcValue(), LD->getSrcValueOffset(), - LD->isVolatile()); + LD->isVolatile(), LD->isNonTemporal(), 0); return DAG.getLoad(VT, dl, LD->getChain(), LD->getBasePtr(), LD->getSrcValue(), LD->getSrcValueOffset(), - LD->isVolatile(), LD->getAlignment()); + LD->isVolatile(), LD->isNonTemporal(), + LD->getAlignment()); } else if (NumElems == 4 && LastLoadedElt == 1) { SDVTList Tys = DAG.getVTList(MVT::v2i64, MVT::Other); SDValue Ops[] = { LD->getChain(), LD->getBasePtr() }; @@ -9469,7 +9490,7 @@ SDValue NewLd = DAG.getLoad(LdVT, LdDL, Ld->getChain(), Ld->getBasePtr(), Ld->getSrcValue(), Ld->getSrcValueOffset(), Ld->isVolatile(), - Ld->getAlignment()); + Ld->isNonTemporal(), Ld->getAlignment()); SDValue NewChain = NewLd.getValue(1); if (TokenFactorIndex != -1) { Ops.push_back(NewChain); @@ -9478,7 +9499,8 @@ } return DAG.getStore(NewChain, StDL, NewLd, St->getBasePtr(), St->getSrcValue(), St->getSrcValueOffset(), - St->isVolatile(), St->getAlignment()); + St->isVolatile(), St->isNonTemporal(), + St->getAlignment()); } // Otherwise, lower to two pairs of 32-bit loads / stores. @@ -9488,10 +9510,11 @@ SDValue LoLd = DAG.getLoad(MVT::i32, LdDL, Ld->getChain(), LoAddr, Ld->getSrcValue(), Ld->getSrcValueOffset(), - Ld->isVolatile(), Ld->getAlignment()); + Ld->isVolatile(), Ld->isNonTemporal(), + Ld->getAlignment()); SDValue HiLd = DAG.getLoad(MVT::i32, LdDL, Ld->getChain(), HiAddr, Ld->getSrcValue(), Ld->getSrcValueOffset()+4, - Ld->isVolatile(), + Ld->isVolatile(), Ld->isNonTemporal(), MinAlign(Ld->getAlignment(), 4)); SDValue NewChain = LoLd.getValue(1); @@ -9508,11 +9531,13 @@ SDValue LoSt = DAG.getStore(NewChain, StDL, LoLd, LoAddr, St->getSrcValue(), St->getSrcValueOffset(), - St->isVolatile(), St->getAlignment()); + St->isVolatile(), St->isNonTemporal(), + St->getAlignment()); SDValue HiSt = DAG.getStore(NewChain, StDL, HiLd, HiAddr, St->getSrcValue(), St->getSrcValueOffset() + 4, St->isVolatile(), + St->isNonTemporal(), MinAlign(St->getAlignment(), 4)); return DAG.getNode(ISD::TokenFactor, StDL, MVT::Other, LoSt, HiSt); } From greened at obbligato.org Mon Feb 15 10:55:07 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:55:07 -0000 Subject: [llvm-commits] [llvm] r96229 - /llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Message-ID: <201002151655.o1FGt7xs006623@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:55:07 2010 New Revision: 96229 URL: http://llvm.org/viewvc/llvm-project?rev=96229&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp?rev=96229&r1=96228&r2=96229&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Mon Feb 15 10:55:07 2010 @@ -282,7 +282,8 @@ DAG.getIntPtrConstant(VA.getLocMemOffset())); MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, - PseudoSourceValue::getStack(), 0)); + PseudoSourceValue::getStack(), 0, + false, false, 0)); } } @@ -426,7 +427,8 @@ // Create the SelectionDAG nodes corresponding to a load //from this parameter SDValue FIN = DAG.getFrameIndex(FI, MVT::i64); - ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0); + ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0, + false, false, 0); } InVals.push_back(ArgVal); } @@ -442,14 +444,16 @@ int FI = MFI->CreateFixedObject(8, -8 * (6 - i), true, false); if (i == 0) VarArgsBase = FI; SDValue SDFI = DAG.getFrameIndex(FI, MVT::i64); - LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0)); + LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0, + false, false, 0)); if (TargetRegisterInfo::isPhysicalRegister(args_float[i])) args_float[i] = AddLiveIn(MF, args_float[i], &Alpha::F8RCRegClass); argt = DAG.getCopyFromReg(Chain, dl, args_float[i], MVT::f64); FI = MFI->CreateFixedObject(8, - 8 * (12 - i), true, false); SDFI = DAG.getFrameIndex(FI, MVT::i64); - LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0)); + LS.push_back(DAG.getStore(Chain, dl, argt, SDFI, NULL, 0, + false, false, 0)); } //Set up a token factor with all the stack traffic @@ -528,11 +532,12 @@ const Value *VAListS = cast(N->getOperand(2))->getValue(); DebugLoc dl = N->getDebugLoc(); - SDValue Base = DAG.getLoad(MVT::i64, dl, Chain, VAListP, VAListS, 0); + SDValue Base = DAG.getLoad(MVT::i64, dl, Chain, VAListP, VAListS, 0, + false, false, 0); SDValue Tmp = DAG.getNode(ISD::ADD, dl, MVT::i64, VAListP, DAG.getConstant(8, MVT::i64)); SDValue Offset = DAG.getExtLoad(ISD::SEXTLOAD, dl, MVT::i64, Base.getValue(1), - Tmp, NULL, 0, MVT::i32); + Tmp, NULL, 0, MVT::i32, false, false, 0); DataPtr = DAG.getNode(ISD::ADD, dl, MVT::i64, Base, Offset); if (N->getValueType(0).isFloatingPoint()) { @@ -547,7 +552,7 @@ SDValue NewOffset = DAG.getNode(ISD::ADD, dl, MVT::i64, Offset, DAG.getConstant(8, MVT::i64)); Chain = DAG.getTruncStore(Offset.getValue(1), dl, NewOffset, Tmp, NULL, 0, - MVT::i32); + MVT::i32, false, false, 0); } /// LowerOperation - Provide custom lowering hooks for some operations. @@ -694,9 +699,10 @@ SDValue Result; if (Op.getValueType() == MVT::i32) Result = DAG.getExtLoad(ISD::SEXTLOAD, dl, MVT::i64, Chain, DataPtr, - NULL, 0, MVT::i32); + NULL, 0, MVT::i32, false, false, 0); else - Result = DAG.getLoad(Op.getValueType(), dl, Chain, DataPtr, NULL, 0); + Result = DAG.getLoad(Op.getValueType(), dl, Chain, DataPtr, NULL, 0, + false, false, 0); return Result; } case ISD::VACOPY: { @@ -706,15 +712,18 @@ const Value *DestS = cast(Op.getOperand(3))->getValue(); const Value *SrcS = cast(Op.getOperand(4))->getValue(); - SDValue Val = DAG.getLoad(getPointerTy(), dl, Chain, SrcP, SrcS, 0); - SDValue Result = DAG.getStore(Val.getValue(1), dl, Val, DestP, DestS, 0); + SDValue Val = DAG.getLoad(getPointerTy(), dl, Chain, SrcP, SrcS, 0, + false, false, 0); + SDValue Result = DAG.getStore(Val.getValue(1), dl, Val, DestP, DestS, 0, + false, false, 0); SDValue NP = DAG.getNode(ISD::ADD, dl, MVT::i64, SrcP, DAG.getConstant(8, MVT::i64)); Val = DAG.getExtLoad(ISD::SEXTLOAD, dl, MVT::i64, Result, - NP, NULL,0, MVT::i32); + NP, NULL,0, MVT::i32, false, false, 0); SDValue NPD = DAG.getNode(ISD::ADD, dl, MVT::i64, DestP, DAG.getConstant(8, MVT::i64)); - return DAG.getTruncStore(Val.getValue(1), dl, Val, NPD, NULL, 0, MVT::i32); + return DAG.getTruncStore(Val.getValue(1), dl, Val, NPD, NULL, 0, MVT::i32, + false, false, 0); } case ISD::VASTART: { SDValue Chain = Op.getOperand(0); @@ -723,11 +732,12 @@ // vastart stores the address of the VarArgsBase and VarArgsOffset SDValue FR = DAG.getFrameIndex(VarArgsBase, MVT::i64); - SDValue S1 = DAG.getStore(Chain, dl, FR, VAListP, VAListS, 0); + SDValue S1 = DAG.getStore(Chain, dl, FR, VAListP, VAListS, 0, + false, false, 0); SDValue SA2 = DAG.getNode(ISD::ADD, dl, MVT::i64, VAListP, DAG.getConstant(8, MVT::i64)); return DAG.getTruncStore(S1, dl, DAG.getConstant(VarArgsOffset, MVT::i64), - SA2, NULL, 0, MVT::i32); + SA2, NULL, 0, MVT::i32, false, false, 0); } case ISD::RETURNADDR: return DAG.getNode(AlphaISD::GlobalRetAddr, DebugLoc::getUnknownLoc(), @@ -749,7 +759,8 @@ SDValue Chain, DataPtr; LowerVAARG(N, Chain, DataPtr, DAG); - SDValue Res = DAG.getLoad(N->getValueType(0), dl, Chain, DataPtr, NULL, 0); + SDValue Res = DAG.getLoad(N->getValueType(0), dl, Chain, DataPtr, NULL, 0, + false, false, 0); Results.push_back(Res); Results.push_back(SDValue(Res.getNode(), 1)); } From greened at obbligato.org Mon Feb 15 10:55:24 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:55:24 -0000 Subject: [llvm-commits] [llvm] r96230 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <201002151655.o1FGtO3D006643@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:55:24 2010 New Revision: 96230 URL: http://llvm.org/viewvc/llvm-project?rev=96230&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=96230&r1=96229&r2=96230&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Feb 15 10:55:24 2010 @@ -863,7 +863,8 @@ return CreateCopyOfByValArgument(Arg, PtrOff, Chain, Flags, DAG, dl); } return DAG.getStore(Chain, dl, Arg, PtrOff, - PseudoSourceValue::getStack(), LocMemOffset); + PseudoSourceValue::getStack(), LocMemOffset, + false, false, 0); } void ARMTargetLowering::PassF64ArgInRegs(DebugLoc dl, SelectionDAG &DAG, @@ -1031,7 +1032,8 @@ CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); Callee = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Callee = DAG.getNode(ARMISD::PIC_ADD, dl, getPointerTy(), Callee, PICLabel); @@ -1052,7 +1054,8 @@ CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); Callee = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Callee = DAG.getNode(ARMISD::PIC_ADD, dl, getPointerTy(), Callee, PICLabel); @@ -1238,7 +1241,8 @@ } CPAddr = DAG.getNode(ARMISD::Wrapper, DL, PtrVT, CPAddr); SDValue Result = DAG.getLoad(PtrVT, DL, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); if (RelocM == Reloc::Static) return Result; SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); @@ -1261,7 +1265,8 @@ SDValue Argument = DAG.getTargetConstantPool(CPV, PtrVT, 4); Argument = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Argument); Argument = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Argument, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); SDValue Chain = Argument.getValue(1); SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); @@ -1308,21 +1313,24 @@ Offset = DAG.getTargetConstantPool(CPV, PtrVT, 4); Offset = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Offset); Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); Chain = Offset.getValue(1); SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); Offset = DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Offset, PICLabel); Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); } else { // local exec model ARMConstantPoolValue *CPV = new ARMConstantPoolValue(GV, "tpoff"); Offset = DAG.getTargetConstantPool(CPV, PtrVT, 4); Offset = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, Offset); Offset = DAG.getLoad(PtrVT, dl, Chain, Offset, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); } // The address of the thread local variable is the add of the thread @@ -1358,13 +1366,15 @@ CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); SDValue Chain = Result.getValue(1); SDValue GOT = DAG.getGLOBAL_OFFSET_TABLE(PtrVT); Result = DAG.getNode(ISD::ADD, dl, PtrVT, Result, GOT); if (!UseGOTOFF) Result = DAG.getLoad(PtrVT, dl, Chain, Result, - PseudoSourceValue::getGOT(), 0); + PseudoSourceValue::getGOT(), 0, + false, false, 0); return Result; } else { // If we have T2 ops, we can materialize the address directly via movt/movw @@ -1376,7 +1386,8 @@ SDValue CPAddr = DAG.getTargetConstantPool(GV, PtrVT, 4); CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); return DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); } } } @@ -1403,7 +1414,8 @@ CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); SDValue Chain = Result.getValue(1); if (RelocM == Reloc::PIC_) { @@ -1413,7 +1425,8 @@ if (Subtarget->GVIsIndirectSymbol(GV, RelocM)) Result = DAG.getLoad(PtrVT, dl, Chain, Result, - PseudoSourceValue::getGOT(), 0); + PseudoSourceValue::getGOT(), 0, + false, false, 0); return Result; } @@ -1434,7 +1447,8 @@ SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4); CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); SDValue PICLabel = DAG.getConstant(ARMPCLabelIndex, MVT::i32); return DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel); } @@ -1467,7 +1481,8 @@ CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr); SDValue Result = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), CPAddr, - PseudoSourceValue::getConstantPool(), 0); + PseudoSourceValue::getConstantPool(), 0, + false, false, 0); SDValue Chain = Result.getValue(1); if (RelocM == Reloc::PIC_) { @@ -1515,7 +1530,8 @@ EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); SDValue FR = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); const Value *SV = cast(Op.getOperand(2))->getValue(); - return DAG.getStore(Op.getOperand(0), dl, FR, Op.getOperand(1), SV, 0); + return DAG.getStore(Op.getOperand(0), dl, FR, Op.getOperand(1), SV, 0, + false, false, 0); } SDValue @@ -1592,7 +1608,8 @@ // Create load node to retrieve arguments from the stack. SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); ArgValue2 = DAG.getLoad(MVT::i32, dl, Root, FIN, - PseudoSourceValue::getFixedStack(FI), 0); + PseudoSourceValue::getFixedStack(FI), 0, + false, false, 0); } else { Reg = MF.addLiveIn(NextVA.getLocReg(), RC); ArgValue2 = DAG.getCopyFromReg(Root, dl, Reg, MVT::i32); @@ -1707,7 +1724,8 @@ // Create load nodes to retrieve arguments from the stack. SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, - PseudoSourceValue::getFixedStack(FI), 0)); + PseudoSourceValue::getFixedStack(FI), 0, + false, false, 0)); } } @@ -1745,7 +1763,8 @@ unsigned VReg = MF.addLiveIn(GPRArgRegs[NumGPRs], RC); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i32); SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, - PseudoSourceValue::getFixedStack(VarArgsFrameIndex), 0); + PseudoSourceValue::getFixedStack(VarArgsFrameIndex), 0, + false, false, 0); MemOps.push_back(Store); FIN = DAG.getNode(ISD::ADD, dl, getPointerTy(), FIN, DAG.getConstant(4, getPointerTy())); @@ -1939,13 +1958,14 @@ } if (getTargetMachine().getRelocationModel() == Reloc::PIC_) { Addr = DAG.getLoad((EVT)MVT::i32, dl, Chain, Addr, - PseudoSourceValue::getJumpTable(), 0); + PseudoSourceValue::getJumpTable(), 0, + false, false, 0); Chain = Addr.getValue(1); Addr = DAG.getNode(ISD::ADD, dl, PTy, Addr, Table); return DAG.getNode(ARMISD::BR_JT, dl, MVT::Other, Chain, Addr, JTI, UId); } else { Addr = DAG.getLoad(PTy, dl, Chain, Addr, - PseudoSourceValue::getJumpTable(), 0); + PseudoSourceValue::getJumpTable(), 0, false, false, 0); Chain = Addr.getValue(1); return DAG.getNode(ARMISD::BR_JT, dl, MVT::Other, Chain, Addr, JTI, UId); } @@ -1993,7 +2013,8 @@ ? ARM::R7 : ARM::R11; SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), dl, FrameReg, VT); while (Depth--) - FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr, NULL, 0); + FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr, NULL, 0, + false, false, 0); return FrameAddr; } @@ -2038,7 +2059,7 @@ Loads[i] = DAG.getLoad(VT, dl, Chain, DAG.getNode(ISD::ADD, dl, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcSVOff + SrcOff); + SrcSV, SrcSVOff + SrcOff, false, false, 0); TFOps[i] = Loads[i].getValue(1); SrcOff += VTSize; } @@ -2047,9 +2068,9 @@ for (i = 0; i < MAX_LOADS_IN_LDM && EmittedNumMemOps + i < NumMemOps; ++i) { TFOps[i] = DAG.getStore(Chain, dl, Loads[i], - DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, - DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstSVOff + DstOff); + DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, + DAG.getConstant(DstOff, MVT::i32)), + DstSV, DstSVOff + DstOff, false, false, 0); DstOff += VTSize; } Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); @@ -2075,7 +2096,7 @@ Loads[i] = DAG.getLoad(VT, dl, Chain, DAG.getNode(ISD::ADD, dl, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcSVOff + SrcOff); + SrcSV, SrcSVOff + SrcOff, false, false, 0); TFOps[i] = Loads[i].getValue(1); ++i; SrcOff += VTSize; @@ -2097,7 +2118,7 @@ TFOps[i] = DAG.getStore(Chain, dl, Loads[i], DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstSVOff + DstOff); + DstSV, DstSVOff + DstOff, false, false, 0); ++i; DstOff += VTSize; BytesLeft -= VTSize; From greened at obbligato.org Mon Feb 15 10:55:37 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:55:37 -0000 Subject: [llvm-commits] [llvm] r96231 - /llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Message-ID: <201002151655.o1FGtboJ006661@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:55:37 2010 New Revision: 96231 URL: http://llvm.org/viewvc/llvm-project?rev=96231&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Modified: llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp?rev=96231&r1=96230&r2=96231&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Mon Feb 15 10:55:37 2010 @@ -206,7 +206,8 @@ int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset(), true, false); SDValue FIN = DAG.getFrameIndex(FI, MVT::i32); - InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0)); + InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0, + false, false, 0)); } } @@ -329,7 +330,7 @@ OffsetN = DAG.getNode(ISD::ADD, dl, MVT::i32, SPN, OffsetN); MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, OffsetN, PseudoSourceValue::getStack(), - Offset)); + Offset, false, false, 0)); } } From greened at obbligato.org Mon Feb 15 10:55:58 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:55:58 -0000 Subject: [llvm-commits] [llvm] r96232 - in /llvm/trunk/lib/Target/CellSPU: SPUISelDAGToDAG.cpp SPUISelLowering.cpp Message-ID: <201002151655.o1FGtwAv006696@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:55:58 2010 New Revision: 96232 URL: http://llvm.org/viewvc/llvm-project?rev=96232&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=96232&r1=96231&r2=96232&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Mon Feb 15 10:55:58 2010 @@ -314,7 +314,7 @@ return SelectCode(CurDAG->getLoad(vecVT, dl, CurDAG->getEntryNode(), CGPoolOffset, PseudoSourceValue::getConstantPool(), 0, - false, Alignment).getNode()); + false, false, Alignment).getNode()); } /// Select - Convert the specified operand from a target-independent to a Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=96232&r1=96231&r2=96232&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Mon Feb 15 10:55:58 2010 @@ -669,7 +669,7 @@ // Re-emit as a v16i8 vector load result = DAG.getLoad(MVT::v16i8, dl, the_chain, basePtr, LN->getSrcValue(), LN->getSrcValueOffset(), - LN->isVolatile(), 16); + LN->isVolatile(), LN->isNonTemporal(), 16); // Update the chain the_chain = result.getValue(1); @@ -820,7 +820,7 @@ // Re-emit as a v16i8 vector load alignLoadVec = DAG.getLoad(MVT::v16i8, dl, the_chain, basePtr, SN->getSrcValue(), SN->getSrcValueOffset(), - SN->isVolatile(), 16); + SN->isVolatile(), SN->isNonTemporal(), 16); // Update the chain the_chain = alignLoadVec.getValue(1); @@ -861,7 +861,8 @@ result = DAG.getStore(the_chain, dl, result, basePtr, LN->getSrcValue(), LN->getSrcValueOffset(), - LN->isVolatile(), LN->getAlignment()); + LN->isVolatile(), LN->isNonTemporal(), + LN->getAlignment()); #if 0 && !defined(NDEBUG) if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { @@ -1086,7 +1087,7 @@ // or we're forced to do vararg int FI = MFI->CreateFixedObject(ObjSize, ArgOffset, true, false); SDValue FIN = DAG.getFrameIndex(FI, PtrVT); - ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0); + ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0, false, false, 0); ArgOffset += StackSlotSize; } @@ -1108,7 +1109,8 @@ true, false); SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); SDValue ArgVal = DAG.getRegister(ArgRegs[ArgRegIdx], MVT::v16i8); - SDValue Store = DAG.getStore(Chain, dl, ArgVal, FIN, NULL, 0); + SDValue Store = DAG.getStore(Chain, dl, ArgVal, FIN, NULL, 0, + false, false, 0); Chain = Store.getOperand(0); MemOps.push_back(Store); @@ -1190,7 +1192,8 @@ if (ArgRegIdx != NumArgRegs) { RegsToPass.push_back(std::make_pair(ArgRegs[ArgRegIdx++], Arg)); } else { - MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0)); + MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0, + false, false, 0)); ArgOffset += StackSlotSize; } break; @@ -1199,7 +1202,8 @@ if (ArgRegIdx != NumArgRegs) { RegsToPass.push_back(std::make_pair(ArgRegs[ArgRegIdx++], Arg)); } else { - MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0)); + MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0, + false, false, 0)); ArgOffset += StackSlotSize; } break; @@ -1212,7 +1216,8 @@ if (ArgRegIdx != NumArgRegs) { RegsToPass.push_back(std::make_pair(ArgRegs[ArgRegIdx++], Arg)); } else { - MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0)); + MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0, + false, false, 0)); ArgOffset += StackSlotSize; } break; From greened at obbligato.org Mon Feb 15 10:56:10 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:56:10 -0000 Subject: [llvm-commits] [llvm] r96233 - /llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Message-ID: <201002151656.o1FGuAtF006711@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:56:10 2010 New Revision: 96233 URL: http://llvm.org/viewvc/llvm-project?rev=96233&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=96233&r1=96232&r2=96233&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Mon Feb 15 10:56:10 2010 @@ -510,7 +510,8 @@ SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i32, 0, MipsII::MO_GOT); SDValue ResNode = DAG.getLoad(MVT::i32, dl, - DAG.getEntryNode(), GA, NULL, 0); + DAG.getEntryNode(), GA, NULL, 0, + false, false, 0); // On functions and global targets not internal linked only // a load from got/GP is necessary for PIC to work. if (!GV->hasLocalLinkage() || isa(GV)) @@ -549,7 +550,8 @@ SDValue Ops[] = { JTI }; HiPart = DAG.getNode(MipsISD::Hi, dl, DAG.getVTList(MVT::i32), Ops, 1); } else // Emit Load from Global Pointer - HiPart = DAG.getLoad(MVT::i32, dl, DAG.getEntryNode(), JTI, NULL, 0); + HiPart = DAG.getLoad(MVT::i32, dl, DAG.getEntryNode(), JTI, NULL, 0, + false, false, 0); SDValue Lo = DAG.getNode(MipsISD::Lo, dl, MVT::i32, JTI); ResNode = DAG.getNode(ISD::ADD, dl, MVT::i32, HiPart, Lo); @@ -586,7 +588,7 @@ SDValue CP = DAG.getTargetConstantPool(C, MVT::i32, N->getAlignment(), N->getOffset(), MipsII::MO_GOT); SDValue Load = DAG.getLoad(MVT::i32, dl, DAG.getEntryNode(), - CP, NULL, 0); + CP, NULL, 0, false, false, 0); SDValue Lo = DAG.getNode(MipsISD::Lo, dl, MVT::i32, CP); ResNode = DAG.getNode(ISD::ADD, dl, MVT::i32, Load, Lo); } @@ -601,7 +603,8 @@ // vastart just stores the address of the VarArgsFrameIndex slot into the // memory location argument. const Value *SV = cast(Op.getOperand(2))->getValue(); - return DAG.getStore(Op.getOperand(0), dl, FI, Op.getOperand(1), SV, 0); + return DAG.getStore(Op.getOperand(0), dl, FI, Op.getOperand(1), SV, 0, + false, false, 0); } //===----------------------------------------------------------------------===// @@ -859,7 +862,8 @@ // emit ISD::STORE whichs stores the // parameter value to a stack Location - MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0)); + MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0, + false, false, 0)); } // Transform all store nodes into one single node because all store @@ -933,7 +937,8 @@ // Reload GP value. FI = MipsFI->getGPFI(); SDValue FIN = DAG.getFrameIndex(FI,getPointerTy()); - SDValue GPLoad = DAG.getLoad(MVT::i32, dl, Chain, FIN, NULL, 0); + SDValue GPLoad = DAG.getLoad(MVT::i32, dl, Chain, FIN, NULL, 0, + false, false, 0); Chain = GPLoad.getValue(1); Chain = DAG.getCopyToReg(Chain, dl, DAG.getRegister(Mips::GP, MVT::i32), GPLoad, SDValue(0,0)); @@ -1097,7 +1102,8 @@ // Create load nodes to retrieve arguments from the stack SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); - InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0)); + InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0, + false, false, 0)); } } @@ -1132,7 +1138,8 @@ int FI = MFI->CreateFixedObject(4, 0, true, false); MipsFI->recordStoreVarArgsFI(FI, -(4+(StackLoc*4))); SDValue PtrOff = DAG.getFrameIndex(FI, getPointerTy()); - OutChains.push_back(DAG.getStore(Chain, dl, ArgValue, PtrOff, NULL, 0)); + OutChains.push_back(DAG.getStore(Chain, dl, ArgValue, PtrOff, NULL, 0, + false, false, 0)); // Record the frame index of the first variable argument // which is a value necessary to VASTART. From greened at obbligato.org Mon Feb 15 10:56:22 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:56:22 -0000 Subject: [llvm-commits] [llvm] r96234 - /llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Message-ID: <201002151656.o1FGuMQ9006730@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:56:22 2010 New Revision: 96234 URL: http://llvm.org/viewvc/llvm-project?rev=96234&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=96234&r1=96233&r2=96234&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Mon Feb 15 10:56:22 2010 @@ -371,7 +371,8 @@ //from this parameter SDValue FIN = DAG.getFrameIndex(FI, MVT::i16); InVals.push_back(DAG.getLoad(VA.getLocVT(), dl, Chain, FIN, - PseudoSourceValue::getFixedStack(FI), 0)); + PseudoSourceValue::getFixedStack(FI), 0, + false, false, 0)); } } @@ -500,7 +501,7 @@ MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, PseudoSourceValue::getStack(), - VA.getLocMemOffset())); + VA.getLocMemOffset(), false, false, 0)); } } @@ -893,13 +894,13 @@ return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), DAG.getNode(ISD::ADD, dl, getPointerTy(), FrameAddr, Offset), - NULL, 0); + NULL, 0, false, false, 0); } // Just load the return address. SDValue RetAddrFI = getReturnAddressFrameIndex(DAG); return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), - RetAddrFI, NULL, 0); + RetAddrFI, NULL, 0, false, false, 0); } SDValue MSP430TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) { @@ -911,7 +912,8 @@ SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), dl, MSP430::FPW, VT); while (Depth--) - FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr, NULL, 0); + FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr, NULL, 0, + false, false, 0); return FrameAddr; } From greened at obbligato.org Mon Feb 15 10:56:34 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:56:34 -0000 Subject: [llvm-commits] [llvm] r96235 - /llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Message-ID: <201002151656.o1FGuYsW006754@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:56:34 2010 New Revision: 96235 URL: http://llvm.org/viewvc/llvm-project?rev=96235&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=96235&r1=96234&r2=96235&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Mon Feb 15 10:56:34 2010 @@ -622,12 +622,12 @@ ChainHi = Chain.getOperand(1); } SDValue Store1 = DAG.getStore(ChainLo, dl, SrcLo, Ptr, NULL, - 0 + StoreOffset); + 0 + StoreOffset, false, false, 0); Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, DAG.getConstant(4, Ptr.getValueType())); SDValue Store2 = DAG.getStore(ChainHi, dl, SrcHi, Ptr, NULL, - 1 + StoreOffset); + 1 + StoreOffset, false, false, 0); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Store1, Store2); From greened at obbligato.org Mon Feb 15 10:56:53 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:56:53 -0000 Subject: [llvm-commits] [llvm] r96236 - /llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Message-ID: <201002151656.o1FGurtB006775@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:56:53 2010 New Revision: 96236 URL: http://llvm.org/viewvc/llvm-project?rev=96236&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=96236&r1=96235&r2=96236&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Mon Feb 15 10:56:53 2010 @@ -1243,7 +1243,8 @@ // If the global is weak or external, we have to go through the lazy // resolution stub. - return DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Lo, NULL, 0); + return DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Lo, NULL, 0, + false, false, 0); } SDValue PPCTargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) { @@ -1355,7 +1356,8 @@ EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); SDValue FR = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); const Value *SV = cast(Op.getOperand(2))->getValue(); - return DAG.getStore(Op.getOperand(0), dl, FR, Op.getOperand(1), SV, 0); + return DAG.getStore(Op.getOperand(0), dl, FR, Op.getOperand(1), SV, 0, + false, false, 0); } // For the 32-bit SVR4 ABI we follow the layout of the va_list struct. @@ -1405,25 +1407,29 @@ // Store first byte : number of int regs SDValue firstStore = DAG.getTruncStore(Op.getOperand(0), dl, ArgGPR, - Op.getOperand(1), SV, 0, MVT::i8); + Op.getOperand(1), SV, 0, MVT::i8, + false, false, 0); uint64_t nextOffset = FPROffset; SDValue nextPtr = DAG.getNode(ISD::ADD, dl, PtrVT, Op.getOperand(1), ConstFPROffset); // Store second byte : number of float regs SDValue secondStore = - DAG.getTruncStore(firstStore, dl, ArgFPR, nextPtr, SV, nextOffset, MVT::i8); + DAG.getTruncStore(firstStore, dl, ArgFPR, nextPtr, SV, nextOffset, MVT::i8, + false, false, 0); nextOffset += StackOffset; nextPtr = DAG.getNode(ISD::ADD, dl, PtrVT, nextPtr, ConstStackOffset); // Store second word : arguments given on stack SDValue thirdStore = - DAG.getStore(secondStore, dl, StackOffsetFI, nextPtr, SV, nextOffset); + DAG.getStore(secondStore, dl, StackOffsetFI, nextPtr, SV, nextOffset, + false, false, 0); nextOffset += FrameOffset; nextPtr = DAG.getNode(ISD::ADD, dl, PtrVT, nextPtr, ConstFrameOffset); // Store third word : arguments given in registers - return DAG.getStore(thirdStore, dl, FR, nextPtr, SV, nextOffset); + return DAG.getStore(thirdStore, dl, FR, nextPtr, SV, nextOffset, + false, false, 0); } @@ -1628,7 +1634,8 @@ // Create load nodes to retrieve arguments from the stack. SDValue FIN = DAG.getFrameIndex(FI, PtrVT); - InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0)); + InVals.push_back(DAG.getLoad(VA.getValVT(), dl, Chain, FIN, NULL, 0, + false, false, 0)); } } @@ -1700,7 +1707,8 @@ unsigned GPRIndex = 0; for (; GPRIndex != VarArgsNumGPR; ++GPRIndex) { SDValue Val = DAG.getRegister(GPArgRegs[GPRIndex], PtrVT); - SDValue Store = DAG.getStore(Chain, dl, Val, FIN, NULL, 0); + SDValue Store = DAG.getStore(Chain, dl, Val, FIN, NULL, 0, + false, false, 0); MemOps.push_back(Store); // Increment the address by four for the next argument to store SDValue PtrOff = DAG.getConstant(PtrVT.getSizeInBits()/8, PtrVT); @@ -1714,7 +1722,8 @@ unsigned VReg = MF.addLiveIn(GPArgRegs[GPRIndex], &PPC::GPRCRegClass); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, PtrVT); - SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0); + SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0, + false, false, 0); MemOps.push_back(Store); // Increment the address by four for the next argument to store SDValue PtrOff = DAG.getConstant(PtrVT.getSizeInBits()/8, PtrVT); @@ -1729,7 +1738,8 @@ unsigned FPRIndex = 0; for (FPRIndex = 0; FPRIndex != VarArgsNumFPR; ++FPRIndex) { SDValue Val = DAG.getRegister(FPArgRegs[FPRIndex], MVT::f64); - SDValue Store = DAG.getStore(Chain, dl, Val, FIN, NULL, 0); + SDValue Store = DAG.getStore(Chain, dl, Val, FIN, NULL, 0, + false, false, 0); MemOps.push_back(Store); // Increment the address by eight for the next argument to store SDValue PtrOff = DAG.getConstant(EVT(MVT::f64).getSizeInBits()/8, @@ -1741,7 +1751,8 @@ unsigned VReg = MF.addLiveIn(FPArgRegs[FPRIndex], &PPC::F8RCRegClass); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::f64); - SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0); + SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0, + false, false, 0); MemOps.push_back(Store); // Increment the address by eight for the next argument to store SDValue PtrOff = DAG.getConstant(EVT(MVT::f64).getSizeInBits()/8, @@ -1903,7 +1914,9 @@ unsigned VReg = MF.addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, PtrVT); SDValue Store = DAG.getTruncStore(Val.getValue(1), dl, Val, FIN, - NULL, 0, ObjSize==1 ? MVT::i8 : MVT::i16 ); + NULL, 0, + ObjSize==1 ? MVT::i8 : MVT::i16, + false, false, 0); MemOps.push_back(Store); ++GPR_idx; } @@ -1921,7 +1934,8 @@ int FI = MFI->CreateFixedObject(PtrByteSize, ArgOffset, true, false); SDValue FIN = DAG.getFrameIndex(FI, PtrVT); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, PtrVT); - SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0); + SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0, + false, false, 0); MemOps.push_back(Store); ++GPR_idx; ArgOffset += PtrByteSize; @@ -2045,7 +2059,8 @@ CurArgOffset + (ArgSize - ObjSize), isImmutable, false); SDValue FIN = DAG.getFrameIndex(FI, PtrVT); - ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0); + ArgVal = DAG.getLoad(ObjectVT, dl, Chain, FIN, NULL, 0, + false, false, 0); } InVals.push_back(ArgVal); @@ -2091,7 +2106,8 @@ VReg = MF.addLiveIn(GPR[GPR_idx], &PPC::GPRCRegClass); SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, PtrVT); - SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0); + SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, NULL, 0, + false, false, 0); MemOps.push_back(Store); // Increment the address by four for the next argument to store SDValue PtrOff = DAG.getConstant(PtrVT.getSizeInBits()/8, PtrVT); @@ -2271,7 +2287,7 @@ // Store relative to framepointer. MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, FIN, PseudoSourceValue::getFixedStack(FI), - 0)); + 0, false, false, 0)); } } @@ -2297,7 +2313,8 @@ EVT VT = isPPC64 ? MVT::i64 : MVT::i32; SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewRetAddr, VT); Chain = DAG.getStore(Chain, dl, OldRetAddr, NewRetAddrFrIdx, - PseudoSourceValue::getFixedStack(NewRetAddr), 0); + PseudoSourceValue::getFixedStack(NewRetAddr), 0, + false, false, 0); // When using the 32/64-bit SVR4 ABI there is no need to move the FP stack // slot as the FP is never overwritten. @@ -2308,7 +2325,8 @@ true, false); SDValue NewFramePtrIdx = DAG.getFrameIndex(NewFPIdx, VT); Chain = DAG.getStore(Chain, dl, OldFP, NewFramePtrIdx, - PseudoSourceValue::getFixedStack(NewFPIdx), 0); + PseudoSourceValue::getFixedStack(NewFPIdx), 0, + false, false, 0); } } return Chain; @@ -2346,14 +2364,16 @@ // Load the LR and FP stack slot for later adjusting. EVT VT = PPCSubTarget.isPPC64() ? MVT::i64 : MVT::i32; LROpOut = getReturnAddrFrameIndex(DAG); - LROpOut = DAG.getLoad(VT, dl, Chain, LROpOut, NULL, 0); + LROpOut = DAG.getLoad(VT, dl, Chain, LROpOut, NULL, 0, + false, false, 0); Chain = SDValue(LROpOut.getNode(), 1); // When using the 32/64-bit SVR4 ABI there is no need to load the FP stack // slot as the FP is never overwritten. if (isDarwinABI) { FPOpOut = getFramePointerFrameIndex(DAG); - FPOpOut = DAG.getLoad(VT, dl, Chain, FPOpOut, NULL, 0); + FPOpOut = DAG.getLoad(VT, dl, Chain, FPOpOut, NULL, 0, + false, false, 0); Chain = SDValue(FPOpOut.getNode(), 1); } } @@ -2395,7 +2415,8 @@ PtrOff = DAG.getNode(ISD::ADD, dl, PtrVT, StackPtr, DAG.getConstant(ArgOffset, PtrVT)); } - MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0)); + MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0, + false, false, 0)); // Calculate and remember argument location. } else CalculateTailCallArgDest(DAG, MF, isPPC64, Arg, SPDiff, ArgOffset, TailCallArguments); @@ -2862,7 +2883,8 @@ PtrOff = DAG.getNode(ISD::ADD, dl, getPointerTy(), StackPtr, PtrOff); MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, - PseudoSourceValue::getStack(), LocMemOffset)); + PseudoSourceValue::getStack(), LocMemOffset, + false, false, 0)); } else { // Calculate and remember argument location. CalculateTailCallArgDest(DAG, MF, false, Arg, SPDiff, LocMemOffset, @@ -3024,7 +3046,7 @@ EVT VT = (Size==1) ? MVT::i8 : MVT::i16; if (GPR_idx != NumGPRs) { SDValue Load = DAG.getExtLoad(ISD::EXTLOAD, dl, PtrVT, Chain, Arg, - NULL, 0, VT); + NULL, 0, VT, false, false, 0); MemOpChains.push_back(Load.getValue(1)); RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); @@ -3061,7 +3083,8 @@ SDValue Const = DAG.getConstant(j, PtrOff.getValueType()); SDValue AddArg = DAG.getNode(ISD::ADD, dl, PtrVT, Arg, Const); if (GPR_idx != NumGPRs) { - SDValue Load = DAG.getLoad(PtrVT, dl, Chain, AddArg, NULL, 0); + SDValue Load = DAG.getLoad(PtrVT, dl, Chain, AddArg, NULL, 0, + false, false, 0); MemOpChains.push_back(Load.getValue(1)); RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); ArgOffset += PtrByteSize; @@ -3092,19 +3115,22 @@ RegsToPass.push_back(std::make_pair(FPR[FPR_idx++], Arg)); if (isVarArg) { - SDValue Store = DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0); + SDValue Store = DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0, + false, false, 0); MemOpChains.push_back(Store); // Float varargs are always shadowed in available integer registers if (GPR_idx != NumGPRs) { - SDValue Load = DAG.getLoad(PtrVT, dl, Store, PtrOff, NULL, 0); + SDValue Load = DAG.getLoad(PtrVT, dl, Store, PtrOff, NULL, 0, + false, false, 0); MemOpChains.push_back(Load.getValue(1)); RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); } if (GPR_idx != NumGPRs && Arg.getValueType() == MVT::f64 && !isPPC64){ SDValue ConstFour = DAG.getConstant(4, PtrOff.getValueType()); PtrOff = DAG.getNode(ISD::ADD, dl, PtrVT, PtrOff, ConstFour); - SDValue Load = DAG.getLoad(PtrVT, dl, Store, PtrOff, NULL, 0); + SDValue Load = DAG.getLoad(PtrVT, dl, Store, PtrOff, NULL, 0, + false, false, 0); MemOpChains.push_back(Load.getValue(1)); RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); } @@ -3147,10 +3173,12 @@ // entirely in R registers. Maybe later. PtrOff = DAG.getNode(ISD::ADD, dl, PtrVT, StackPtr, DAG.getConstant(ArgOffset, PtrVT)); - SDValue Store = DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0); + SDValue Store = DAG.getStore(Chain, dl, Arg, PtrOff, NULL, 0, + false, false, 0); MemOpChains.push_back(Store); if (VR_idx != NumVRs) { - SDValue Load = DAG.getLoad(MVT::v4f32, dl, Store, PtrOff, NULL, 0); + SDValue Load = DAG.getLoad(MVT::v4f32, dl, Store, PtrOff, NULL, 0, + false, false, 0); MemOpChains.push_back(Load.getValue(1)); RegsToPass.push_back(std::make_pair(VR[VR_idx++], Load)); } @@ -3160,7 +3188,8 @@ break; SDValue Ix = DAG.getNode(ISD::ADD, dl, PtrVT, PtrOff, DAG.getConstant(i, PtrVT)); - SDValue Load = DAG.getLoad(PtrVT, dl, Store, Ix, NULL, 0); + SDValue Load = DAG.getLoad(PtrVT, dl, Store, Ix, NULL, 0, + false, false, 0); MemOpChains.push_back(Load.getValue(1)); RegsToPass.push_back(std::make_pair(GPR[GPR_idx++], Load)); } @@ -3225,7 +3254,8 @@ // TOC save area offset. SDValue PtrOff = DAG.getIntPtrConstant(40); SDValue AddPtr = DAG.getNode(ISD::ADD, dl, PtrVT, StackPtr, PtrOff); - Chain = DAG.getStore(Val.getValue(1), dl, Val, AddPtr, NULL, 0); + Chain = DAG.getStore(Val.getValue(1), dl, Val, AddPtr, NULL, 0, + false, false, 0); } // Build a sequence of copy-to-reg nodes chained together with token chain @@ -3300,13 +3330,15 @@ SDValue SaveSP = Op.getOperand(1); // Load the old link SP. - SDValue LoadLinkSP = DAG.getLoad(PtrVT, dl, Chain, StackPtr, NULL, 0); + SDValue LoadLinkSP = DAG.getLoad(PtrVT, dl, Chain, StackPtr, NULL, 0, + false, false, 0); // Restore the stack pointer. Chain = DAG.getCopyToReg(LoadLinkSP.getValue(1), dl, SP, SaveSP); // Store the old link SP. - return DAG.getStore(Chain, dl, LoadLinkSP, StackPtr, NULL, 0); + return DAG.getStore(Chain, dl, LoadLinkSP, StackPtr, NULL, 0, + false, false, 0); } @@ -3483,14 +3515,16 @@ SDValue FIPtr = DAG.CreateStackTemporary(MVT::f64); // Emit a store to the stack slot. - SDValue Chain = DAG.getStore(DAG.getEntryNode(), dl, Tmp, FIPtr, NULL, 0); + SDValue Chain = DAG.getStore(DAG.getEntryNode(), dl, Tmp, FIPtr, NULL, 0, + false, false, 0); // Result is a load from the stack slot. If loading 4 bytes, make sure to // add in a bias. if (Op.getValueType() == MVT::i32) FIPtr = DAG.getNode(ISD::ADD, dl, FIPtr.getValueType(), FIPtr, DAG.getConstant(4, FIPtr.getValueType())); - return DAG.getLoad(Op.getValueType(), dl, Chain, FIPtr, NULL, 0); + return DAG.getLoad(Op.getValueType(), dl, Chain, FIPtr, NULL, 0, + false, false, 0); } SDValue PPCTargetLowering::LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG) { @@ -3533,7 +3567,7 @@ DAG.getMemIntrinsicNode(PPCISD::STD_32, dl, DAG.getVTList(MVT::Other), Ops, 4, MVT::i64, MMO); // Load the value as a double. - SDValue Ld = DAG.getLoad(MVT::f64, dl, Store, FIdx, NULL, 0); + SDValue Ld = DAG.getLoad(MVT::f64, dl, Store, FIdx, NULL, 0, false, false, 0); // FCFID it and return it. SDValue FP = DAG.getNode(PPCISD::FCFID, dl, MVT::f64, Ld); @@ -3578,12 +3612,13 @@ int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, PtrVT); SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Chain, - StackSlot, NULL, 0); + StackSlot, NULL, 0, false, false, 0); // Load FP Control Word from low 32 bits of stack slot. SDValue Four = DAG.getConstant(4, PtrVT); SDValue Addr = DAG.getNode(ISD::ADD, dl, PtrVT, StackSlot, Four); - SDValue CWD = DAG.getLoad(MVT::i32, dl, Store, Addr, NULL, 0); + SDValue CWD = DAG.getLoad(MVT::i32, dl, Store, Addr, NULL, 0, + false, false, 0); // Transform as necessary SDValue CWD1 = @@ -4249,9 +4284,11 @@ // Store the input value into Value#0 of the stack slot. SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, - Op.getOperand(0), FIdx, NULL, 0); + Op.getOperand(0), FIdx, NULL, 0, + false, false, 0); // Load it out. - return DAG.getLoad(Op.getValueType(), dl, Store, FIdx, NULL, 0); + return DAG.getLoad(Op.getValueType(), dl, Store, FIdx, NULL, 0, + false, false, 0); } SDValue PPCTargetLowering::LowerMUL(SDValue Op, SelectionDAG &DAG) { @@ -5460,7 +5497,8 @@ // to the stack. FuncInfo->setLRStoreRequired(); return DAG.getLoad(getPointerTy(), dl, - DAG.getEntryNode(), RetAddrFI, NULL, 0); + DAG.getEntryNode(), RetAddrFI, NULL, 0, + false, false, 0); } SDValue PPCTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) { From greened at obbligato.org Mon Feb 15 10:57:02 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:57:02 -0000 Subject: [llvm-commits] [llvm] r96237 - /llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Message-ID: <201002151657.o1FGv22q006801@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:57:02 2010 New Revision: 96237 URL: http://llvm.org/viewvc/llvm-project?rev=96237&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=96237&r1=96236&r2=96237&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Mon Feb 15 10:57:02 2010 @@ -134,7 +134,8 @@ SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); SDValue Load; if (ObjectVT == MVT::i32) { - Load = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0); + Load = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0, + false, false, 0); } else { ISD::LoadExtType LoadOp = ISD::SEXTLOAD; @@ -143,7 +144,7 @@ FIPtr = DAG.getNode(ISD::ADD, dl, MVT::i32, FIPtr, DAG.getConstant(Offset, MVT::i32)); Load = DAG.getExtLoad(LoadOp, dl, MVT::i32, Chain, FIPtr, - NULL, 0, ObjectVT); + NULL, 0, ObjectVT, false, false, 0); Load = DAG.getNode(ISD::TRUNCATE, dl, ObjectVT, Load); } InVals.push_back(Load); @@ -167,7 +168,8 @@ int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset, true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); - SDValue Load = DAG.getLoad(MVT::f32, dl, Chain, FIPtr, NULL, 0); + SDValue Load = DAG.getLoad(MVT::f32, dl, Chain, FIPtr, NULL, 0, + false, false, 0); InVals.push_back(Load); } ArgOffset += 4; @@ -189,7 +191,8 @@ int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset, true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); - HiVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0); + HiVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0, + false, false, 0); } SDValue LoVal; @@ -201,7 +204,8 @@ int FrameIdx = MF.getFrameInfo()->CreateFixedObject(4, ArgOffset+4, true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); - LoVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0); + LoVal = DAG.getLoad(MVT::i32, dl, Chain, FIPtr, NULL, 0, + false, false, 0); } // Compose the two halves together into an i64 unit. @@ -235,7 +239,8 @@ true, false); SDValue FIPtr = DAG.getFrameIndex(FrameIdx, MVT::i32); - OutChains.push_back(DAG.getStore(DAG.getRoot(), dl, Arg, FIPtr, NULL, 0)); + OutChains.push_back(DAG.getStore(DAG.getRoot(), dl, Arg, FIPtr, NULL, 0, + false, false, 0)); ArgOffset += 4; } @@ -339,7 +344,8 @@ // FIXME: VERIFY THAT 68 IS RIGHT. SDValue PtrOff = DAG.getIntPtrConstant(VA.getLocMemOffset()+68); PtrOff = DAG.getNode(ISD::ADD, MVT::i32, StackPtr, PtrOff); - MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0)); + MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0, + false, false, 0)); } #else @@ -385,14 +391,17 @@ // out the parts as integers. Top part goes in a reg. SDValue StackPtr = DAG.CreateStackTemporary(MVT::f64, MVT::i32); SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, - Val, StackPtr, NULL, 0); + Val, StackPtr, NULL, 0, + false, false, 0); // Sparc is big-endian, so the high part comes first. - SDValue Hi = DAG.getLoad(MVT::i32, dl, Store, StackPtr, NULL, 0, 0); + SDValue Hi = DAG.getLoad(MVT::i32, dl, Store, StackPtr, NULL, 0, + false, false, 0); // Increment the pointer to the other half. StackPtr = DAG.getNode(ISD::ADD, dl, StackPtr.getValueType(), StackPtr, DAG.getIntPtrConstant(4)); // Load the low part. - SDValue Lo = DAG.getLoad(MVT::i32, dl, Store, StackPtr, NULL, 0, 0); + SDValue Lo = DAG.getLoad(MVT::i32, dl, Store, StackPtr, NULL, 0, + false, false, 0); RegsToPass.push_back(std::make_pair(ArgRegs[RegsToPass.size()], Hi)); @@ -435,7 +444,8 @@ SDValue PtrOff = DAG.getConstant(ArgOffset, MVT::i32); PtrOff = DAG.getNode(ISD::ADD, dl, MVT::i32, StackPtr, PtrOff); MemOpChains.push_back(DAG.getStore(Chain, dl, ValToStore, - PtrOff, NULL, 0)); + PtrOff, NULL, 0, + false, false, 0)); } ArgOffset += ObjSize; } @@ -759,7 +769,7 @@ SDValue AbsAddr = DAG.getNode(ISD::ADD, dl, MVT::i32, GlobalBase, RelAddr); return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), - AbsAddr, NULL, 0); + AbsAddr, NULL, 0, false, false, 0); } SDValue SparcTargetLowering::LowerConstantPool(SDValue Op, @@ -780,7 +790,7 @@ SDValue AbsAddr = DAG.getNode(ISD::ADD, dl, MVT::i32, GlobalBase, RelAddr); return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), - AbsAddr, NULL, 0); + AbsAddr, NULL, 0, false, false, 0); } static SDValue LowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG) { @@ -872,7 +882,8 @@ DAG.getConstant(TLI.getVarArgsFrameOffset(), MVT::i32)); const Value *SV = cast(Op.getOperand(2))->getValue(); - return DAG.getStore(Op.getOperand(0), dl, Offset, Op.getOperand(1), SV, 0); + return DAG.getStore(Op.getOperand(0), dl, Offset, Op.getOperand(1), SV, 0, + false, false, 0); } static SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) { @@ -882,21 +893,23 @@ SDValue VAListPtr = Node->getOperand(1); const Value *SV = cast(Node->getOperand(2))->getValue(); DebugLoc dl = Node->getDebugLoc(); - SDValue VAList = DAG.getLoad(MVT::i32, dl, InChain, VAListPtr, SV, 0); + SDValue VAList = DAG.getLoad(MVT::i32, dl, InChain, VAListPtr, SV, 0, + false, false, 0); // Increment the pointer, VAList, to the next vaarg SDValue NextPtr = DAG.getNode(ISD::ADD, dl, MVT::i32, VAList, DAG.getConstant(VT.getSizeInBits()/8, MVT::i32)); // Store the incremented VAList to the legalized pointer InChain = DAG.getStore(VAList.getValue(1), dl, NextPtr, - VAListPtr, SV, 0); + VAListPtr, SV, 0, false, false, 0); // Load the actual argument out of the pointer VAList, unless this is an // f64 load. if (VT != MVT::f64) - return DAG.getLoad(VT, dl, InChain, VAList, NULL, 0); + return DAG.getLoad(VT, dl, InChain, VAList, NULL, 0, false, false, 0); // Otherwise, load it as i64, then do a bitconvert. - SDValue V = DAG.getLoad(MVT::i64, dl, InChain, VAList, NULL, 0); + SDValue V = DAG.getLoad(MVT::i64, dl, InChain, VAList, NULL, 0, + false, false, 0); // Bit-Convert the value to f64. SDValue Ops[2] = { From greened at obbligato.org Mon Feb 15 10:57:13 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:57:13 -0000 Subject: [llvm-commits] [llvm] r96238 - /llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Message-ID: <201002151657.o1FGvDR4006827@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:57:13 2010 New Revision: 96238 URL: http://llvm.org/viewvc/llvm-project?rev=96238&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=96238&r1=96237&r2=96238&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Mon Feb 15 10:57:13 2010 @@ -337,7 +337,8 @@ // from this parameter SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); ArgValue = DAG.getLoad(LocVT, dl, Chain, FIN, - PseudoSourceValue::getFixedStack(FI), 0); + PseudoSourceValue::getFixedStack(FI), 0, + false, false, 0); } // If this is an 8/16/32-bit value, it is really passed promoted to 64 @@ -435,7 +436,8 @@ DAG.getIntPtrConstant(Offset)); MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, PtrOff, - PseudoSourceValue::getStack(), Offset)); + PseudoSourceValue::getStack(), Offset, + false, false, 0)); } } @@ -738,7 +740,7 @@ if (ExtraLoadRequired) Result = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), Result, - PseudoSourceValue::getGOT(), 0); + PseudoSourceValue::getGOT(), 0, false, false, 0); // If there was a non-zero offset that we didn't fold, create an explicit // addition for it. From greened at obbligato.org Mon Feb 15 10:57:44 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 16:57:44 -0000 Subject: [llvm-commits] [llvm] r96239 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Message-ID: <201002151657.o1FGviGI006871@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 10:57:43 2010 New Revision: 96239 URL: http://llvm.org/viewvc/llvm-project?rev=96239&view=rev Log: Remove an assumption of default arguments. This is in anticipation of a change to SelectionDAG build APIs. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=96239&r1=96238&r2=96239&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Feb 15 10:57:43 2010 @@ -652,9 +652,10 @@ // FIXME: optimize the case where the src/dest is a load or store? SDValue Store = CurDAG->getTruncStore(CurDAG->getEntryNode(), dl, N->getOperand(0), - MemTmp, NULL, 0, MemVT); + MemTmp, NULL, 0, MemVT, + false, false, 0); SDValue Result = CurDAG->getExtLoad(ISD::EXTLOAD, dl, DstVT, Store, MemTmp, - NULL, 0, MemVT); + NULL, 0, MemVT, false, false, 0); // We're about to replace all uses of the FP_ROUND/FP_EXTEND with the // extload we created. This will cause general havok on the dag because From greened at obbligato.org Mon Feb 15 11:00:31 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 17:00:31 -0000 Subject: [llvm-commits] [llvm] r96240 - in /llvm/trunk: include/llvm/CodeGen/ lib/CodeGen/SelectionDAG/ Message-ID: <201002151700.o1FH0Wps007060@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 11:00:31 2010 New Revision: 96240 URL: http://llvm.org/viewvc/llvm-project?rev=96240&view=rev Log: Add non-temporal flags and remove an assumption of default arguments. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Mon Feb 15 11:00:31 2010 @@ -581,18 +581,18 @@ /// determined by their operands, and they produce a value AND a token chain. /// SDValue getLoad(EVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr, - const Value *SV, int SVOffset, bool isVolatile=false, - unsigned Alignment=0); + const Value *SV, int SVOffset, bool isVolatile, + bool isNonTemporal, unsigned Alignment); SDValue getExtLoad(ISD::LoadExtType ExtType, DebugLoc dl, EVT VT, - SDValue Chain, SDValue Ptr, const Value *SV, - int SVOffset, EVT MemVT, bool isVolatile=false, - unsigned Alignment=0); + SDValue Chain, SDValue Ptr, const Value *SV, + int SVOffset, EVT MemVT, bool isVolatile, + bool isNonTemporal, unsigned Alignment); SDValue getIndexedLoad(SDValue OrigLoad, DebugLoc dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM); SDValue getLoad(ISD::MemIndexedMode AM, DebugLoc dl, ISD::LoadExtType ExtType, EVT VT, SDValue Chain, SDValue Ptr, SDValue Offset, const Value *SV, int SVOffset, EVT MemVT, - bool isVolatile=false, unsigned Alignment=0); + bool isVolatile, bool isNonTemporal, unsigned Alignment); SDValue getLoad(ISD::MemIndexedMode AM, DebugLoc dl, ISD::LoadExtType ExtType, EVT VT, SDValue Chain, SDValue Ptr, SDValue Offset, EVT MemVT, MachineMemOperand *MMO); @@ -600,13 +600,14 @@ /// getStore - Helper function to build ISD::STORE nodes. /// SDValue getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, - const Value *SV, int SVOffset, bool isVolatile=false, - unsigned Alignment=0); + const Value *SV, int SVOffset, bool isVolatile, + bool isNonTemporal, unsigned Alignment); SDValue getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, MachineMemOperand *MMO); SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, - const Value *SV, int SVOffset, EVT TVT, - bool isVolatile=false, unsigned Alignment=0); + const Value *SV, int SVOffset, EVT TVT, + bool isNonTemporal, bool isVolatile, + unsigned Alignment); SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, EVT TVT, MachineMemOperand *MMO); SDValue getIndexedStore(SDValue OrigStoe, DebugLoc dl, SDValue Base, Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Mon Feb 15 11:00:31 2010 @@ -1596,6 +1596,7 @@ } bool isVolatile() const { return (SubclassData >> 5) & 1; } + bool isNonTemporal() const { return MMO->isNonTemporal(); } /// Returns the SrcValue and offset that describes the location of the access const Value *getSrcValue() const { return MMO->getValue(); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Feb 15 11:00:31 2010 @@ -1881,7 +1881,8 @@ LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), MemVT, - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); AddToWorkList(N); CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1)); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -1903,7 +1904,8 @@ LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), MemVT, - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); AddToWorkList(N); CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1)); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -1935,7 +1937,8 @@ DAG.getExtLoad(ISD::ZEXTLOAD, LN0->getDebugLoc(), LoadResultTy, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), - ExtVT, LN0->isVolatile(), LN0->getAlignment()); + ExtVT, LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); AddToWorkList(N); CombineTo(LN0, NewLoad, NewLoad.getValue(1)); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -1970,7 +1973,8 @@ DAG.getExtLoad(ISD::ZEXTLOAD, LN0->getDebugLoc(), LoadResultTy, LN0->getChain(), NewPtr, LN0->getSrcValue(), LN0->getSrcValueOffset(), - ExtVT, LN0->isVolatile(), Alignment); + ExtVT, LN0->isVolatile(), LN0->isNonTemporal(), + Alignment); AddToWorkList(N); CombineTo(LN0, Load, Load.getValue(1)); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -3143,7 +3147,8 @@ LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), N0.getValueType(), - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); SDValue Trunc = DAG.getNode(ISD::TRUNCATE, N0.getDebugLoc(), N0.getValueType(), ExtLoad); @@ -3185,7 +3190,8 @@ LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), MemVT, - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.getNode(), DAG.getNode(ISD::TRUNCATE, N0.getDebugLoc(), @@ -3315,7 +3321,8 @@ LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), N0.getValueType(), - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); SDValue Trunc = DAG.getNode(ISD::TRUNCATE, N0.getDebugLoc(), N0.getValueType(), ExtLoad); @@ -3357,7 +3364,8 @@ LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), MemVT, - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.getNode(), DAG.getNode(ISD::TRUNCATE, N0.getDebugLoc(), N0.getValueType(), @@ -3471,7 +3479,8 @@ LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), N0.getValueType(), - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); SDValue Trunc = DAG.getNode(ISD::TRUNCATE, N0.getDebugLoc(), N0.getValueType(), ExtLoad); @@ -3513,7 +3522,8 @@ VT, LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), MemVT, - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.getNode(), DAG.getNode(ISD::TRUNCATE, N0.getDebugLoc(), @@ -3636,10 +3646,11 @@ SDValue Load = (ExtType == ISD::NON_EXTLOAD) ? DAG.getLoad(VT, N0.getDebugLoc(), LN0->getChain(), NewPtr, LN0->getSrcValue(), LN0->getSrcValueOffset() + PtrOff, - LN0->isVolatile(), NewAlign) + LN0->isVolatile(), LN0->isNonTemporal(), NewAlign) : DAG.getExtLoad(ExtType, N0.getDebugLoc(), VT, LN0->getChain(), NewPtr, LN0->getSrcValue(), LN0->getSrcValueOffset() + PtrOff, - ExtVT, LN0->isVolatile(), NewAlign); + ExtVT, LN0->isVolatile(), LN0->isNonTemporal(), + NewAlign); // Replace the old load's chain with the new load's chain. WorkListRemover DeadNodes(*this); @@ -3726,7 +3737,8 @@ LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT, - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1)); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -3742,7 +3754,8 @@ LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), EVT, - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.getNode(), ExtLoad, ExtLoad.getValue(1)); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -3826,7 +3839,7 @@ (!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT))) return DAG.getLoad(VT, N->getDebugLoc(), LD1->getChain(), LD1->getBasePtr(), LD1->getSrcValue(), - LD1->getSrcValueOffset(), false, Align); + LD1->getSrcValueOffset(), false, false, Align); } return SDValue(); @@ -3896,7 +3909,8 @@ SDValue Load = DAG.getLoad(VT, N->getDebugLoc(), LN0->getChain(), LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), - LN0->isVolatile(), OrigAlign); + LN0->isVolatile(), LN0->isNonTemporal(), + OrigAlign); AddToWorkList(N); CombineTo(N0.getNode(), DAG.getNode(ISD::BIT_CONVERT, N0.getDebugLoc(), @@ -4492,7 +4506,8 @@ LN0->getBasePtr(), LN0->getSrcValue(), LN0->getSrcValueOffset(), N0.getValueType(), - LN0->isVolatile(), LN0->getAlignment()); + LN0->isVolatile(), LN0->isNonTemporal(), + LN0->getAlignment()); CombineTo(N, ExtLoad); CombineTo(N0.getNode(), DAG.getNode(ISD::FP_ROUND, N0.getDebugLoc(), @@ -4960,7 +4975,7 @@ LD->getValueType(0), Chain, Ptr, LD->getSrcValue(), LD->getSrcValueOffset(), LD->getMemoryVT(), - LD->isVolatile(), Align); + LD->isVolatile(), LD->isNonTemporal(), Align); } } @@ -5042,7 +5057,8 @@ ReplLoad = DAG.getLoad(N->getValueType(0), LD->getDebugLoc(), BetterChain, Ptr, LD->getSrcValue(), LD->getSrcValueOffset(), - LD->isVolatile(), LD->getAlignment()); + LD->isVolatile(), LD->isNonTemporal(), + LD->getAlignment()); } else { ReplLoad = DAG.getExtLoad(LD->getExtensionType(), LD->getDebugLoc(), LD->getValueType(0), @@ -5050,6 +5066,7 @@ LD->getSrcValueOffset(), LD->getMemoryVT(), LD->isVolatile(), + LD->isNonTemporal(), LD->getAlignment()); } @@ -5149,13 +5166,14 @@ SDValue NewLD = DAG.getLoad(NewVT, N0.getDebugLoc(), LD->getChain(), NewPtr, LD->getSrcValue(), LD->getSrcValueOffset(), - LD->isVolatile(), NewAlign); + LD->isVolatile(), LD->isNonTemporal(), + NewAlign); SDValue NewVal = DAG.getNode(Opc, Value.getDebugLoc(), NewVT, NewLD, DAG.getConstant(NewImm, NewVT)); SDValue NewST = DAG.getStore(Chain, N->getDebugLoc(), NewVal, NewPtr, ST->getSrcValue(), ST->getSrcValueOffset(), - false, NewAlign); + false, false, NewAlign); AddToWorkList(NewPtr.getNode()); AddToWorkList(NewLD.getNode()); @@ -5184,7 +5202,7 @@ return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), ST->getMemoryVT(), - ST->isVolatile(), Align); + ST->isVolatile(), ST->isNonTemporal(), Align); } } @@ -5201,7 +5219,8 @@ TLI.isOperationLegalOrCustom(ISD::STORE, SVT))) return DAG.getStore(Chain, N->getDebugLoc(), Value.getOperand(0), Ptr, ST->getSrcValue(), - ST->getSrcValueOffset(), ST->isVolatile(), OrigAlign); + ST->getSrcValueOffset(), ST->isVolatile(), + ST->isNonTemporal(), OrigAlign); } // Turn 'store float 1.0, Ptr' -> 'store int 0x12345678, Ptr' @@ -5227,7 +5246,7 @@ return DAG.getStore(Chain, N->getDebugLoc(), Tmp, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), ST->isVolatile(), - ST->getAlignment()); + ST->isNonTemporal(), ST->getAlignment()); } break; case MVT::f64: @@ -5239,7 +5258,7 @@ return DAG.getStore(Chain, N->getDebugLoc(), Tmp, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), ST->isVolatile(), - ST->getAlignment()); + ST->isNonTemporal(), ST->getAlignment()); } else if (!ST->isVolatile() && TLI.isOperationLegalOrCustom(ISD::STORE, MVT::i32)) { // Many FP stores are not made apparent until after legalize, e.g. for @@ -5253,18 +5272,21 @@ int SVOffset = ST->getSrcValueOffset(); unsigned Alignment = ST->getAlignment(); bool isVolatile = ST->isVolatile(); + bool isNonTemporal = ST->isNonTemporal(); SDValue St0 = DAG.getStore(Chain, ST->getDebugLoc(), Lo, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), - isVolatile, ST->getAlignment()); + isVolatile, isNonTemporal, + ST->getAlignment()); Ptr = DAG.getNode(ISD::ADD, N->getDebugLoc(), Ptr.getValueType(), Ptr, DAG.getConstant(4, Ptr.getValueType())); SVOffset += 4; Alignment = MinAlign(Alignment, 4U); SDValue St1 = DAG.getStore(Chain, ST->getDebugLoc(), Hi, Ptr, ST->getSrcValue(), - SVOffset, isVolatile, Alignment); + SVOffset, isVolatile, isNonTemporal, + Alignment); return DAG.getNode(ISD::TokenFactor, N->getDebugLoc(), MVT::Other, St0, St1); } @@ -5286,12 +5308,13 @@ if (ST->isTruncatingStore()) { ReplStore = DAG.getTruncStore(BetterChain, N->getDebugLoc(), Value, Ptr, ST->getSrcValue(),ST->getSrcValueOffset(), - ST->getMemoryVT(), - ST->isVolatile(), ST->getAlignment()); + ST->getMemoryVT(), ST->isVolatile(), + ST->isNonTemporal(), ST->getAlignment()); } else { ReplStore = DAG.getStore(BetterChain, N->getDebugLoc(), Value, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), - ST->isVolatile(), ST->getAlignment()); + ST->isVolatile(), ST->isNonTemporal(), + ST->getAlignment()); } // Create token to keep both nodes around. @@ -5325,7 +5348,8 @@ return DAG.getTruncStore(Chain, N->getDebugLoc(), Shorter, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), ST->getMemoryVT(), - ST->isVolatile(), ST->getAlignment()); + ST->isVolatile(), ST->isNonTemporal(), + ST->getAlignment()); // Otherwise, see if we can simplify the operation with // SimplifyDemandedBits, which only works if the value has a single use. @@ -5358,7 +5382,8 @@ return DAG.getTruncStore(Chain, N->getDebugLoc(), Value.getOperand(0), Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), ST->getMemoryVT(), - ST->isVolatile(), ST->getAlignment()); + ST->isVolatile(), ST->isNonTemporal(), + ST->getAlignment()); } return ReduceLoadOpStoreWidth(N); @@ -5503,7 +5528,7 @@ return DAG.getLoad(LVT, N->getDebugLoc(), LN0->getChain(), NewPtr, LN0->getSrcValue(), LN0->getSrcValueOffset(), - LN0->isVolatile(), Align); + LN0->isVolatile(), LN0->isNonTemporal(), Align); } return SDValue(); @@ -5883,6 +5908,7 @@ LLD->getChain(), Addr, 0, 0, LLD->isVolatile(), + LLD->isNonTemporal(), LLD->getAlignment()); } else { Load = DAG.getExtLoad(LLD->getExtensionType(), @@ -5891,6 +5917,7 @@ LLD->getChain(), Addr, 0, 0, LLD->getMemoryVT(), LLD->isVolatile(), + LLD->isNonTemporal(), LLD->getAlignment()); } @@ -5998,7 +6025,7 @@ CstOffset); return DAG.getLoad(TV->getValueType(0), DL, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, false, - Alignment); + false, Alignment); } } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Feb 15 11:00:31 2010 @@ -377,9 +377,10 @@ return DAG.getExtLoad(ISD::EXTLOAD, dl, OrigVT, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), - 0, VT, false, Alignment); + 0, VT, false, false, Alignment); return DAG.getLoad(OrigVT, dl, DAG.getEntryNode(), CPIdx, - PseudoSourceValue::getConstantPool(), 0, false, Alignment); + PseudoSourceValue::getConstantPool(), 0, false, false, + Alignment); } /// ExpandUnalignedStore - Expands an unaligned store to 2 half-size stores. @@ -402,7 +403,8 @@ // FIXME: Does not handle truncating floating point stores! SDValue Result = DAG.getNode(ISD::BIT_CONVERT, dl, intVT, Val); return DAG.getStore(Chain, dl, Result, Ptr, ST->getSrcValue(), - SVOffset, ST->isVolatile(), Alignment); + SVOffset, ST->isVolatile(), ST->isNonTemporal(), + Alignment); } else { // Do a (aligned) store to a stack slot, then copy from the stack slot // to the final destination using (unaligned) integer loads and stores. @@ -418,7 +420,8 @@ // Perform the original store, only redirected to the stack slot. SDValue Store = DAG.getTruncStore(Chain, dl, - Val, StackPtr, NULL, 0, StoredVT); + Val, StackPtr, NULL, 0, StoredVT, + false, false, 0); SDValue Increment = DAG.getConstant(RegBytes, TLI.getPointerTy()); SmallVector Stores; unsigned Offset = 0; @@ -426,11 +429,12 @@ // Do all but one copies using the full register width. for (unsigned i = 1; i < NumRegs; i++) { // Load one integer register's worth from the stack slot. - SDValue Load = DAG.getLoad(RegVT, dl, Store, StackPtr, NULL, 0); + SDValue Load = DAG.getLoad(RegVT, dl, Store, StackPtr, NULL, 0, + false, false, 0); // Store it to the final location. Remember the store. Stores.push_back(DAG.getStore(Load.getValue(1), dl, Load, Ptr, ST->getSrcValue(), SVOffset + Offset, - ST->isVolatile(), + ST->isVolatile(), ST->isNonTemporal(), MinAlign(ST->getAlignment(), Offset))); // Increment the pointers. Offset += RegBytes; @@ -446,11 +450,12 @@ // Load from the stack slot. SDValue Load = DAG.getExtLoad(ISD::EXTLOAD, dl, RegVT, Store, StackPtr, - NULL, 0, MemVT); + NULL, 0, MemVT, false, false, 0); Stores.push_back(DAG.getTruncStore(Load.getValue(1), dl, Load, Ptr, ST->getSrcValue(), SVOffset + Offset, MemVT, ST->isVolatile(), + ST->isNonTemporal(), MinAlign(ST->getAlignment(), Offset))); // The order of the stores doesn't matter - say it with a TokenFactor. return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &Stores[0], @@ -474,13 +479,14 @@ SDValue Store1, Store2; Store1 = DAG.getTruncStore(Chain, dl, TLI.isLittleEndian()?Lo:Hi, Ptr, ST->getSrcValue(), SVOffset, NewStoredVT, - ST->isVolatile(), Alignment); + ST->isVolatile(), ST->isNonTemporal(), Alignment); Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, DAG.getConstant(IncrementSize, TLI.getPointerTy())); Alignment = MinAlign(Alignment, IncrementSize); Store2 = DAG.getTruncStore(Chain, dl, TLI.isLittleEndian()?Hi:Lo, Ptr, ST->getSrcValue(), SVOffset + IncrementSize, - NewStoredVT, ST->isVolatile(), Alignment); + NewStoredVT, ST->isVolatile(), ST->isNonTemporal(), + Alignment); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Store1, Store2); } @@ -502,7 +508,7 @@ // then bitconvert to floating point or vector. SDValue newLoad = DAG.getLoad(intVT, dl, Chain, Ptr, LD->getSrcValue(), SVOffset, LD->isVolatile(), - LD->getAlignment()); + LD->isNonTemporal(), LD->getAlignment()); SDValue Result = DAG.getNode(ISD::BIT_CONVERT, dl, LoadedVT, newLoad); if (VT.isFloatingPoint() && LoadedVT != VT) Result = DAG.getNode(ISD::FP_EXTEND, dl, VT, Result); @@ -530,10 +536,11 @@ // Load one integer register's worth from the original location. SDValue Load = DAG.getLoad(RegVT, dl, Chain, Ptr, LD->getSrcValue(), SVOffset + Offset, LD->isVolatile(), + LD->isNonTemporal(), MinAlign(LD->getAlignment(), Offset)); // Follow the load with a store to the stack slot. Remember the store. Stores.push_back(DAG.getStore(Load.getValue(1), dl, Load, StackPtr, - NULL, 0)); + NULL, 0, false, false, 0)); // Increment the pointers. Offset += RegBytes; Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, Increment); @@ -546,12 +553,13 @@ SDValue Load = DAG.getExtLoad(ISD::EXTLOAD, dl, RegVT, Chain, Ptr, LD->getSrcValue(), SVOffset + Offset, MemVT, LD->isVolatile(), + LD->isNonTemporal(), MinAlign(LD->getAlignment(), Offset)); // Follow the load with a store to the stack slot. Remember the store. // On big-endian machines this requires a truncating store to ensure // that the bits end up in the right place. Stores.push_back(DAG.getTruncStore(Load.getValue(1), dl, Load, StackPtr, - NULL, 0, MemVT)); + NULL, 0, MemVT, false, false, 0)); // The order of the stores doesn't matter - say it with a TokenFactor. SDValue TF = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &Stores[0], @@ -559,7 +567,7 @@ // Finally, perform the original load only redirected to the stack slot. Load = DAG.getExtLoad(LD->getExtensionType(), dl, VT, TF, StackBase, - NULL, 0, LoadedVT); + NULL, 0, LoadedVT, false, false, 0); // Callers expect a MERGE_VALUES node. SDValue Ops[] = { Load, TF }; @@ -588,20 +596,22 @@ SDValue Lo, Hi; if (TLI.isLittleEndian()) { Lo = DAG.getExtLoad(ISD::ZEXTLOAD, dl, VT, Chain, Ptr, LD->getSrcValue(), - SVOffset, NewLoadedVT, LD->isVolatile(), Alignment); + SVOffset, NewLoadedVT, LD->isVolatile(), + LD->isNonTemporal(), Alignment); Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, DAG.getConstant(IncrementSize, TLI.getPointerTy())); Hi = DAG.getExtLoad(HiExtType, dl, VT, Chain, Ptr, LD->getSrcValue(), SVOffset + IncrementSize, NewLoadedVT, LD->isVolatile(), - MinAlign(Alignment, IncrementSize)); + LD->isNonTemporal(), MinAlign(Alignment, IncrementSize)); } else { Hi = DAG.getExtLoad(HiExtType, dl, VT, Chain, Ptr, LD->getSrcValue(), - SVOffset, NewLoadedVT, LD->isVolatile(), Alignment); + SVOffset, NewLoadedVT, LD->isVolatile(), + LD->isNonTemporal(), Alignment); Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, DAG.getConstant(IncrementSize, TLI.getPointerTy())); Lo = DAG.getExtLoad(ISD::ZEXTLOAD, dl, VT, Chain, Ptr, LD->getSrcValue(), SVOffset + IncrementSize, NewLoadedVT, LD->isVolatile(), - MinAlign(Alignment, IncrementSize)); + LD->isNonTemporal(), MinAlign(Alignment, IncrementSize)); } // aggregate the two parts @@ -643,7 +653,8 @@ // Store the vector. SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Tmp1, StackPtr, - PseudoSourceValue::getFixedStack(SPFI), 0); + PseudoSourceValue::getFixedStack(SPFI), 0, + false, false, 0); // Truncate or zero extend offset to target pointer type. unsigned CastOpc = IdxVT.bitsGT(PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND; @@ -654,10 +665,12 @@ SDValue StackPtr2 = DAG.getNode(ISD::ADD, dl, IdxVT, Tmp3, StackPtr); // Store the scalar value. Ch = DAG.getTruncStore(Ch, dl, Tmp2, StackPtr2, - PseudoSourceValue::getFixedStack(SPFI), 0, EltVT); + PseudoSourceValue::getFixedStack(SPFI), 0, EltVT, + false, false, 0); // Load the updated vector. return DAG.getLoad(VT, dl, Ch, StackPtr, - PseudoSourceValue::getFixedStack(SPFI), 0); + PseudoSourceValue::getFixedStack(SPFI), 0, + false, false, 0); } @@ -702,6 +715,7 @@ int SVOffset = ST->getSrcValueOffset(); unsigned Alignment = ST->getAlignment(); bool isVolatile = ST->isVolatile(); + bool isNonTemporal = ST->isNonTemporal(); DebugLoc dl = ST->getDebugLoc(); if (ConstantFPSDNode *CFP = dyn_cast(ST->getValue())) { if (CFP->getValueType(0) == MVT::f32 && @@ -710,14 +724,14 @@ bitcastToAPInt().zextOrTrunc(32), MVT::i32); return DAG.getStore(Tmp1, dl, Tmp3, Tmp2, ST->getSrcValue(), - SVOffset, isVolatile, Alignment); + SVOffset, isVolatile, isNonTemporal, Alignment); } else if (CFP->getValueType(0) == MVT::f64) { // If this target supports 64-bit registers, do a single 64-bit store. if (getTypeAction(MVT::i64) == Legal) { Tmp3 = DAG.getConstant(CFP->getValueAPF().bitcastToAPInt(). zextOrTrunc(64), MVT::i64); return DAG.getStore(Tmp1, dl, Tmp3, Tmp2, ST->getSrcValue(), - SVOffset, isVolatile, Alignment); + SVOffset, isVolatile, isNonTemporal, Alignment); } else if (getTypeAction(MVT::i32) == Legal && !ST->isVolatile()) { // Otherwise, if the target supports 32-bit registers, use 2 32-bit // stores. If the target supports neither 32- nor 64-bits, this @@ -728,11 +742,11 @@ if (TLI.isBigEndian()) std::swap(Lo, Hi); Lo = DAG.getStore(Tmp1, dl, Lo, Tmp2, ST->getSrcValue(), - SVOffset, isVolatile, Alignment); + SVOffset, isVolatile, isNonTemporal, Alignment); Tmp2 = DAG.getNode(ISD::ADD, dl, Tmp2.getValueType(), Tmp2, DAG.getIntPtrConstant(4)); Hi = DAG.getStore(Tmp1, dl, Hi, Tmp2, ST->getSrcValue(), SVOffset+4, - isVolatile, MinAlign(Alignment, 4U)); + isVolatile, isNonTemporal, MinAlign(Alignment, 4U)); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Lo, Hi); } @@ -1108,7 +1122,8 @@ Tmp1 = DAG.getLoad(NVT, dl, Tmp1, Tmp2, LD->getSrcValue(), LD->getSrcValueOffset(), - LD->isVolatile(), LD->getAlignment()); + LD->isVolatile(), LD->isNonTemporal(), + LD->getAlignment()); Tmp3 = LegalizeOp(DAG.getNode(ISD::BIT_CONVERT, dl, VT, Tmp1)); Tmp4 = LegalizeOp(Tmp1.getValue(1)); break; @@ -1125,6 +1140,7 @@ int SVOffset = LD->getSrcValueOffset(); unsigned Alignment = LD->getAlignment(); bool isVolatile = LD->isVolatile(); + bool isNonTemporal = LD->isNonTemporal(); if (SrcWidth != SrcVT.getStoreSizeInBits() && // Some targets pretend to have an i1 loading operation, and actually @@ -1150,7 +1166,7 @@ Result = DAG.getExtLoad(NewExtType, dl, Node->getValueType(0), Tmp1, Tmp2, LD->getSrcValue(), SVOffset, - NVT, isVolatile, Alignment); + NVT, isVolatile, isNonTemporal, Alignment); Ch = Result.getValue(1); // The chain. @@ -1187,7 +1203,7 @@ Lo = DAG.getExtLoad(ISD::ZEXTLOAD, dl, Node->getValueType(0), Tmp1, Tmp2, LD->getSrcValue(), SVOffset, RoundVT, isVolatile, - Alignment); + isNonTemporal, Alignment); // Load the remaining ExtraWidth bits. IncrementSize = RoundWidth / 8; @@ -1195,7 +1211,7 @@ DAG.getIntPtrConstant(IncrementSize)); Hi = DAG.getExtLoad(ExtType, dl, Node->getValueType(0), Tmp1, Tmp2, LD->getSrcValue(), SVOffset + IncrementSize, - ExtraVT, isVolatile, + ExtraVT, isVolatile, isNonTemporal, MinAlign(Alignment, IncrementSize)); // Build a factor node to remember that this load is independent of the @@ -1215,7 +1231,7 @@ // Load the top RoundWidth bits. Hi = DAG.getExtLoad(ExtType, dl, Node->getValueType(0), Tmp1, Tmp2, LD->getSrcValue(), SVOffset, RoundVT, isVolatile, - Alignment); + isNonTemporal, Alignment); // Load the remaining ExtraWidth bits. IncrementSize = RoundWidth / 8; @@ -1224,7 +1240,7 @@ Lo = DAG.getExtLoad(ISD::ZEXTLOAD, dl, Node->getValueType(0), Tmp1, Tmp2, LD->getSrcValue(), SVOffset + IncrementSize, - ExtraVT, isVolatile, + ExtraVT, isVolatile, isNonTemporal, MinAlign(Alignment, IncrementSize)); // Build a factor node to remember that this load is independent of the @@ -1284,7 +1300,8 @@ (SrcVT == MVT::f64 && Node->getValueType(0) == MVT::f128)) { SDValue Load = DAG.getLoad(SrcVT, dl, Tmp1, Tmp2, LD->getSrcValue(), LD->getSrcValueOffset(), - LD->isVolatile(), LD->getAlignment()); + LD->isVolatile(), LD->isNonTemporal(), + LD->getAlignment()); Result = DAG.getNode(ISD::FP_EXTEND, dl, Node->getValueType(0), Load); Tmp1 = LegalizeOp(Result); // Relegalize new nodes. @@ -1297,7 +1314,8 @@ Result = DAG.getExtLoad(ISD::EXTLOAD, dl, Node->getValueType(0), Tmp1, Tmp2, LD->getSrcValue(), LD->getSrcValueOffset(), SrcVT, - LD->isVolatile(), LD->getAlignment()); + LD->isVolatile(), LD->isNonTemporal(), + LD->getAlignment()); SDValue ValRes; if (ExtType == ISD::SEXTLOAD) ValRes = DAG.getNode(ISD::SIGN_EXTEND_INREG, dl, @@ -1325,6 +1343,7 @@ int SVOffset = ST->getSrcValueOffset(); unsigned Alignment = ST->getAlignment(); bool isVolatile = ST->isVolatile(); + bool isNonTemporal = ST->isNonTemporal(); if (!ST->isTruncatingStore()) { if (SDNode *OptStore = OptimizeFloatStore(ST).getNode()) { @@ -1361,7 +1380,7 @@ TLI.getTypeToPromoteTo(ISD::STORE, VT), Tmp3); Result = DAG.getStore(Tmp1, dl, Tmp3, Tmp2, ST->getSrcValue(), SVOffset, isVolatile, - Alignment); + isNonTemporal, Alignment); break; } break; @@ -1379,7 +1398,8 @@ EVT NVT = EVT::getIntegerVT(*DAG.getContext(), StVT.getStoreSizeInBits()); Tmp3 = DAG.getZeroExtendInReg(Tmp3, dl, StVT); Result = DAG.getTruncStore(Tmp1, dl, Tmp3, Tmp2, ST->getSrcValue(), - SVOffset, NVT, isVolatile, Alignment); + SVOffset, NVT, isVolatile, isNonTemporal, + Alignment); } else if (StWidth & (StWidth - 1)) { // If not storing a power-of-2 number of bits, expand as two stores. assert(!StVT.isVector() && "Unsupported truncstore!"); @@ -1399,7 +1419,7 @@ // Store the bottom RoundWidth bits. Lo = DAG.getTruncStore(Tmp1, dl, Tmp3, Tmp2, ST->getSrcValue(), SVOffset, RoundVT, - isVolatile, Alignment); + isVolatile, isNonTemporal, Alignment); // Store the remaining ExtraWidth bits. IncrementSize = RoundWidth / 8; @@ -1409,6 +1429,7 @@ DAG.getConstant(RoundWidth, TLI.getShiftAmountTy())); Hi = DAG.getTruncStore(Tmp1, dl, Hi, Tmp2, ST->getSrcValue(), SVOffset + IncrementSize, ExtraVT, isVolatile, + isNonTemporal, MinAlign(Alignment, IncrementSize)); } else { // Big endian - avoid unaligned stores. @@ -1417,7 +1438,8 @@ Hi = DAG.getNode(ISD::SRL, dl, Tmp3.getValueType(), Tmp3, DAG.getConstant(ExtraWidth, TLI.getShiftAmountTy())); Hi = DAG.getTruncStore(Tmp1, dl, Hi, Tmp2, ST->getSrcValue(), - SVOffset, RoundVT, isVolatile, Alignment); + SVOffset, RoundVT, isVolatile, isNonTemporal, + Alignment); // Store the remaining ExtraWidth bits. IncrementSize = RoundWidth / 8; @@ -1425,6 +1447,7 @@ DAG.getIntPtrConstant(IncrementSize)); Lo = DAG.getTruncStore(Tmp1, dl, Tmp3, Tmp2, ST->getSrcValue(), SVOffset + IncrementSize, ExtraVT, isVolatile, + isNonTemporal, MinAlign(Alignment, IncrementSize)); } @@ -1457,7 +1480,8 @@ assert(isTypeLegal(StVT) && "Do not know how to expand this store!"); Tmp3 = DAG.getNode(ISD::TRUNCATE, dl, StVT, Tmp3); Result = DAG.getStore(Tmp1, dl, Tmp3, Tmp2, ST->getSrcValue(), - SVOffset, isVolatile, Alignment); + SVOffset, isVolatile, isNonTemporal, + Alignment); break; } } @@ -1484,7 +1508,8 @@ DebugLoc dl = Op.getDebugLoc(); // Store the value to a temporary stack slot, then LOAD the returned part. SDValue StackPtr = DAG.CreateStackTemporary(Vec.getValueType()); - SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, NULL, 0); + SDValue Ch = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, NULL, 0, + false, false, 0); // Add the offset to the index. unsigned EltSize = @@ -1500,10 +1525,12 @@ StackPtr = DAG.getNode(ISD::ADD, dl, Idx.getValueType(), Idx, StackPtr); if (Op.getValueType().isVector()) - return DAG.getLoad(Op.getValueType(), dl, Ch, StackPtr, NULL, 0); + return DAG.getLoad(Op.getValueType(), dl, Ch, StackPtr, NULL, 0, + false, false, 0); else return DAG.getExtLoad(ISD::EXTLOAD, dl, Op.getValueType(), Ch, StackPtr, - NULL, 0, Vec.getValueType().getVectorElementType()); + NULL, 0, Vec.getValueType().getVectorElementType(), + false, false, 0); } SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) { @@ -1535,10 +1562,12 @@ // If EltVT smaller than OpVT, only store the bits necessary. if (!OpVT.isVector() && EltVT.bitsLT(OpVT)) { Stores.push_back(DAG.getTruncStore(DAG.getEntryNode(), dl, - Node->getOperand(i), Idx, SV, Offset, EltVT)); + Node->getOperand(i), Idx, SV, Offset, + EltVT, false, false, 0)); } else Stores.push_back(DAG.getStore(DAG.getEntryNode(), dl, - Node->getOperand(i), Idx, SV, Offset)); + Node->getOperand(i), Idx, SV, Offset, + false, false, 0)); } SDValue StoreChain; @@ -1549,7 +1578,7 @@ StoreChain = DAG.getEntryNode(); // Result is a load from the stack slot. - return DAG.getLoad(VT, dl, StoreChain, FIPtr, SV, 0); + return DAG.getLoad(VT, dl, StoreChain, FIPtr, SV, 0, false, false, 0); } SDValue SelectionDAGLegalize::ExpandFCOPYSIGN(SDNode* Node) { @@ -1572,12 +1601,14 @@ SDValue StackPtr = DAG.CreateStackTemporary(Tmp2.getValueType()); SDValue StorePtr = StackPtr, LoadPtr = StackPtr; SDValue Ch = - DAG.getStore(DAG.getEntryNode(), dl, Tmp2, StorePtr, NULL, 0); + DAG.getStore(DAG.getEntryNode(), dl, Tmp2, StorePtr, NULL, 0, + false, false, 0); if (Tmp2.getValueType() == MVT::f64 && TLI.isLittleEndian()) LoadPtr = DAG.getNode(ISD::ADD, dl, StackPtr.getValueType(), LoadPtr, DAG.getIntPtrConstant(4)); SignBit = DAG.getExtLoad(ISD::SEXTLOAD, dl, TLI.getPointerTy(), - Ch, LoadPtr, NULL, 0, MVT::i32); + Ch, LoadPtr, NULL, 0, MVT::i32, + false, false, 0); } SignBit = DAG.getSetCC(dl, TLI.getSetCCResultType(SignBit.getValueType()), @@ -1701,20 +1732,21 @@ if (SrcSize > SlotSize) Store = DAG.getTruncStore(DAG.getEntryNode(), dl, SrcOp, FIPtr, - SV, 0, SlotVT, false, SrcAlign); + SV, 0, SlotVT, false, false, SrcAlign); else { assert(SrcSize == SlotSize && "Invalid store"); Store = DAG.getStore(DAG.getEntryNode(), dl, SrcOp, FIPtr, - SV, 0, false, SrcAlign); + SV, 0, false, false, SrcAlign); } // Result is a load from the stack slot. if (SlotSize == DestSize) - return DAG.getLoad(DestVT, dl, Store, FIPtr, SV, 0, false, DestAlign); + return DAG.getLoad(DestVT, dl, Store, FIPtr, SV, 0, false, false, + DestAlign); assert(SlotSize < DestSize && "Unknown extension!"); return DAG.getExtLoad(ISD::EXTLOAD, dl, DestVT, Store, FIPtr, SV, 0, SlotVT, - false, DestAlign); + false, false, DestAlign); } SDValue SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) { @@ -1729,9 +1761,11 @@ SDValue Ch = DAG.getTruncStore(DAG.getEntryNode(), dl, Node->getOperand(0), StackPtr, PseudoSourceValue::getFixedStack(SPFI), 0, - Node->getValueType(0).getVectorElementType()); + Node->getValueType(0).getVectorElementType(), + false, false, 0); return DAG.getLoad(Node->getValueType(0), dl, Ch, StackPtr, - PseudoSourceValue::getFixedStack(SPFI), 0); + PseudoSourceValue::getFixedStack(SPFI), 0, + false, false, 0); } @@ -1805,7 +1839,7 @@ unsigned Alignment = cast(CPIdx)->getAlignment(); return DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, - false, Alignment); + false, false, Alignment); } if (!MoreThanTwoValues) { @@ -1943,13 +1977,16 @@ } // store the lo of the constructed double - based on integer input SDValue Store1 = DAG.getStore(DAG.getEntryNode(), dl, - Op0Mapped, Lo, NULL, 0); + Op0Mapped, Lo, NULL, 0, + false, false, 0); // initial hi portion of constructed double SDValue InitialHi = DAG.getConstant(0x43300000u, MVT::i32); // store the hi of the constructed double - biased exponent - SDValue Store2=DAG.getStore(Store1, dl, InitialHi, Hi, NULL, 0); + SDValue Store2=DAG.getStore(Store1, dl, InitialHi, Hi, NULL, 0, + false, false, 0); // load the constructed double - SDValue Load = DAG.getLoad(MVT::f64, dl, Store2, StackSlot, NULL, 0); + SDValue Load = DAG.getLoad(MVT::f64, dl, Store2, StackSlot, NULL, 0, + false, false, 0); // FP constant to bias correct the final result SDValue Bias = DAG.getConstantFP(isSigned ? BitsToDouble(0x4330000080000000ULL) : @@ -2004,13 +2041,13 @@ if (DestVT == MVT::f32) FudgeInReg = DAG.getLoad(MVT::f32, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, - false, Alignment); + false, false, Alignment); else { FudgeInReg = LegalizeOp(DAG.getExtLoad(ISD::EXTLOAD, dl, DestVT, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, - MVT::f32, false, Alignment)); + MVT::f32, false, false, Alignment)); } return DAG.getNode(ISD::FADD, dl, DestVT, Tmp1, FudgeInReg); @@ -2350,16 +2387,19 @@ EVT VT = Node->getValueType(0); Tmp1 = Node->getOperand(0); Tmp2 = Node->getOperand(1); - SDValue VAList = DAG.getLoad(TLI.getPointerTy(), dl, Tmp1, Tmp2, V, 0); + SDValue VAList = DAG.getLoad(TLI.getPointerTy(), dl, Tmp1, Tmp2, V, 0, + false, false, 0); // Increment the pointer, VAList, to the next vaarg Tmp3 = DAG.getNode(ISD::ADD, dl, TLI.getPointerTy(), VAList, DAG.getConstant(TLI.getTargetData()-> getTypeAllocSize(VT.getTypeForEVT(*DAG.getContext())), TLI.getPointerTy())); // Store the incremented VAList to the legalized pointer - Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Tmp2, V, 0); + Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Tmp2, V, 0, + false, false, 0); // Load the actual argument out of the pointer VAList - Results.push_back(DAG.getLoad(VT, dl, Tmp3, VAList, NULL, 0)); + Results.push_back(DAG.getLoad(VT, dl, Tmp3, VAList, NULL, 0, + false, false, 0)); Results.push_back(Results[0].getValue(1)); break; } @@ -2369,8 +2409,9 @@ const Value *VD = cast(Node->getOperand(3))->getValue(); const Value *VS = cast(Node->getOperand(4))->getValue(); Tmp1 = DAG.getLoad(TLI.getPointerTy(), dl, Node->getOperand(0), - Node->getOperand(2), VS, 0); - Tmp1 = DAG.getStore(Tmp1.getValue(1), dl, Tmp1, Node->getOperand(1), VD, 0); + Node->getOperand(2), VS, 0, false, false, 0); + Tmp1 = DAG.getStore(Tmp1.getValue(1), dl, Tmp1, Node->getOperand(1), VD, 0, + false, false, 0); Results.push_back(Tmp1); break; } @@ -2827,7 +2868,8 @@ EVT MemVT = EVT::getIntegerVT(*DAG.getContext(), EntrySize * 8); SDValue LD = DAG.getExtLoad(ISD::SEXTLOAD, dl, PTy, Chain, Addr, - PseudoSourceValue::getJumpTable(), 0, MemVT); + PseudoSourceValue::getJumpTable(), 0, MemVT, + false, false, 0); Addr = LD; if (TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_) { // For PIC, the sequence is: Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Mon Feb 15 11:00:31 2010 @@ -444,7 +444,7 @@ NewL = DAG.getLoad(L->getAddressingMode(), dl, L->getExtensionType(), NVT, L->getChain(), L->getBasePtr(), L->getOffset(), L->getSrcValue(), L->getSrcValueOffset(), NVT, - L->isVolatile(), L->getAlignment()); + L->isVolatile(), L->isNonTemporal(), L->getAlignment()); // Legalized the chain result - switch anything that used the old chain to // use the new one. ReplaceValueWith(SDValue(N, 1), NewL.getValue(1)); @@ -456,8 +456,8 @@ L->getMemoryVT(), L->getChain(), L->getBasePtr(), L->getOffset(), L->getSrcValue(), L->getSrcValueOffset(), - L->getMemoryVT(), - L->isVolatile(), L->getAlignment()); + L->getMemoryVT(), L->isVolatile(), + L->isNonTemporal(), L->getAlignment()); // Legalized the chain result - switch anything that used the old chain to // use the new one. ReplaceValueWith(SDValue(N, 1), NewL.getValue(1)); @@ -755,7 +755,8 @@ return DAG.getStore(ST->getChain(), dl, Val, ST->getBasePtr(), ST->getSrcValue(), ST->getSrcValueOffset(), - ST->isVolatile(), ST->getAlignment()); + ST->isVolatile(), ST->isNonTemporal(), + ST->getAlignment()); } @@ -1073,8 +1074,8 @@ Hi = DAG.getExtLoad(LD->getExtensionType(), dl, NVT, Chain, Ptr, LD->getSrcValue(), LD->getSrcValueOffset(), - LD->getMemoryVT(), - LD->isVolatile(), LD->getAlignment()); + LD->getMemoryVT(), LD->isVolatile(), + LD->isNonTemporal(), LD->getAlignment()); // Remember the chain. Chain = Hi.getValue(1); @@ -1382,6 +1383,6 @@ return DAG.getTruncStore(Chain, N->getDebugLoc(), Hi, Ptr, ST->getSrcValue(), ST->getSrcValueOffset(), - ST->getMemoryVT(), - ST->isVolatile(), ST->getAlignment()); + ST->getMemoryVT(), ST->isVolatile(), + ST->isNonTemporal(), ST->getAlignment()); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Mon Feb 15 11:00:31 2010 @@ -359,7 +359,7 @@ SDValue Res = DAG.getExtLoad(ExtType, dl, NVT, N->getChain(), N->getBasePtr(), N->getSrcValue(), N->getSrcValueOffset(), N->getMemoryVT(), N->isVolatile(), - N->getAlignment()); + N->isNonTemporal(), N->getAlignment()); // Legalized the chain result - switch anything that used the old chain to // use the new one. @@ -873,6 +873,7 @@ int SVOffset = N->getSrcValueOffset(); unsigned Alignment = N->getAlignment(); bool isVolatile = N->isVolatile(); + bool isNonTemporal = N->isNonTemporal(); DebugLoc dl = N->getDebugLoc(); SDValue Val = GetPromotedInteger(N->getValue()); // Get promoted value. @@ -880,7 +881,7 @@ // Truncate the value and store the result. return DAG.getTruncStore(Ch, dl, Val, Ptr, N->getSrcValue(), SVOffset, N->getMemoryVT(), - isVolatile, Alignment); + isVolatile, isNonTemporal, Alignment); } SDValue DAGTypeLegalizer::PromoteIntOp_TRUNCATE(SDNode *N) { @@ -1500,6 +1501,7 @@ int SVOffset = N->getSrcValueOffset(); unsigned Alignment = N->getAlignment(); bool isVolatile = N->isVolatile(); + bool isNonTemporal = N->isNonTemporal(); DebugLoc dl = N->getDebugLoc(); assert(NVT.isByteSized() && "Expanded type not byte sized!"); @@ -1508,7 +1510,7 @@ EVT MemVT = N->getMemoryVT(); Lo = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr, N->getSrcValue(), SVOffset, - MemVT, isVolatile, Alignment); + MemVT, isVolatile, isNonTemporal, Alignment); // Remember the chain. Ch = Lo.getValue(1); @@ -1530,7 +1532,7 @@ } else if (TLI.isLittleEndian()) { // Little-endian - low bits are at low addresses. Lo = DAG.getLoad(NVT, dl, Ch, Ptr, N->getSrcValue(), SVOffset, - isVolatile, Alignment); + isVolatile, isNonTemporal, Alignment); unsigned ExcessBits = N->getMemoryVT().getSizeInBits() - NVT.getSizeInBits(); @@ -1542,7 +1544,8 @@ DAG.getIntPtrConstant(IncrementSize)); Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr, N->getSrcValue(), SVOffset+IncrementSize, NEVT, - isVolatile, MinAlign(Alignment, IncrementSize)); + isVolatile, isNonTemporal, + MinAlign(Alignment, IncrementSize)); // Build a factor node to remember that this load is independent of the // other one. @@ -1560,7 +1563,7 @@ Hi = DAG.getExtLoad(ExtType, dl, NVT, Ch, Ptr, N->getSrcValue(), SVOffset, EVT::getIntegerVT(*DAG.getContext(), MemVT.getSizeInBits() - ExcessBits), - isVolatile, Alignment); + isVolatile, isNonTemporal, Alignment); // Increment the pointer to the other half. Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, @@ -1569,7 +1572,8 @@ Lo = DAG.getExtLoad(ISD::ZEXTLOAD, dl, NVT, Ch, Ptr, N->getSrcValue(), SVOffset+IncrementSize, EVT::getIntegerVT(*DAG.getContext(), ExcessBits), - isVolatile, MinAlign(Alignment, IncrementSize)); + isVolatile, isNonTemporal, + MinAlign(Alignment, IncrementSize)); // Build a factor node to remember that this load is independent of the // other one. @@ -2212,6 +2216,7 @@ int SVOffset = N->getSrcValueOffset(); unsigned Alignment = N->getAlignment(); bool isVolatile = N->isVolatile(); + bool isNonTemporal = N->isNonTemporal(); DebugLoc dl = N->getDebugLoc(); SDValue Lo, Hi; @@ -2220,13 +2225,14 @@ if (N->getMemoryVT().bitsLE(NVT)) { GetExpandedInteger(N->getValue(), Lo, Hi); return DAG.getTruncStore(Ch, dl, Lo, Ptr, N->getSrcValue(), SVOffset, - N->getMemoryVT(), isVolatile, Alignment); + N->getMemoryVT(), isVolatile, isNonTemporal, + Alignment); } else if (TLI.isLittleEndian()) { // Little-endian - low bits are at low addresses. GetExpandedInteger(N->getValue(), Lo, Hi); Lo = DAG.getStore(Ch, dl, Lo, Ptr, N->getSrcValue(), SVOffset, - isVolatile, Alignment); + isVolatile, isNonTemporal, Alignment); unsigned ExcessBits = N->getMemoryVT().getSizeInBits() - NVT.getSizeInBits(); @@ -2238,7 +2244,8 @@ DAG.getIntPtrConstant(IncrementSize)); Hi = DAG.getTruncStore(Ch, dl, Hi, Ptr, N->getSrcValue(), SVOffset+IncrementSize, NEVT, - isVolatile, MinAlign(Alignment, IncrementSize)); + isVolatile, isNonTemporal, + MinAlign(Alignment, IncrementSize)); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Lo, Hi); } else { // Big-endian - high bits are at low addresses. Favor aligned stores at @@ -2264,7 +2271,8 @@ // Store both the high bits and maybe some of the low bits. Hi = DAG.getTruncStore(Ch, dl, Hi, Ptr, N->getSrcValue(), - SVOffset, HiVT, isVolatile, Alignment); + SVOffset, HiVT, isVolatile, isNonTemporal, + Alignment); // Increment the pointer to the other half. Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, @@ -2273,7 +2281,8 @@ Lo = DAG.getTruncStore(Ch, dl, Lo, Ptr, N->getSrcValue(), SVOffset+IncrementSize, EVT::getIntegerVT(*DAG.getContext(), ExcessBits), - isVolatile, MinAlign(Alignment, IncrementSize)); + isVolatile, isNonTemporal, + MinAlign(Alignment, IncrementSize)); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Lo, Hi); } } @@ -2341,7 +2350,7 @@ // FIXME: Avoid the extend by constructing the right constant pool? SDValue Fudge = DAG.getExtLoad(ISD::EXTLOAD, dl, DstVT, DAG.getEntryNode(), FudgePtr, NULL, 0, MVT::f32, - false, Alignment); + false, false, Alignment); return DAG.getNode(ISD::FADD, dl, DstVT, SignedConv, Fudge); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Mon Feb 15 11:00:31 2010 @@ -871,9 +871,10 @@ // the source and destination types. SDValue StackPtr = DAG.CreateStackTemporary(Op.getValueType(), DestVT); // Emit a store to the stack slot. - SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Op, StackPtr, NULL, 0); + SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Op, StackPtr, NULL, 0, + false, false, 0); // Result is a load from the stack slot. - return DAG.getLoad(DestVT, dl, Store, StackPtr, NULL, 0); + return DAG.getLoad(DestVT, dl, Store, StackPtr, NULL, 0, false, false, 0); } /// CustomLowerNode - Replace the node's results with custom code provided Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Mon Feb 15 11:00:31 2010 @@ -122,10 +122,11 @@ const Value *SV = PseudoSourceValue::getFixedStack(SPFI); // Emit a store to the stack slot. - SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, InOp, StackPtr, SV, 0); + SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, InOp, StackPtr, SV, 0, + false, false, 0); // Load the first half from the stack slot. - Lo = DAG.getLoad(NOutVT, dl, Store, StackPtr, SV, 0); + Lo = DAG.getLoad(NOutVT, dl, Store, StackPtr, SV, 0, false, false, 0); // Increment the pointer to the other half. unsigned IncrementSize = NOutVT.getSizeInBits() / 8; @@ -134,7 +135,7 @@ // Load the second half from the stack slot. Hi = DAG.getLoad(NOutVT, dl, Store, StackPtr, SV, IncrementSize, false, - MinAlign(Alignment, IncrementSize)); + false, MinAlign(Alignment, IncrementSize)); // Handle endianness of the load. if (TLI.isBigEndian()) @@ -205,11 +206,12 @@ int SVOffset = LD->getSrcValueOffset(); unsigned Alignment = LD->getAlignment(); bool isVolatile = LD->isVolatile(); + bool isNonTemporal = LD->isNonTemporal(); assert(NVT.isByteSized() && "Expanded type not byte sized!"); Lo = DAG.getLoad(NVT, dl, Chain, Ptr, LD->getSrcValue(), SVOffset, - isVolatile, Alignment); + isVolatile, isNonTemporal, Alignment); // Increment the pointer to the other half. unsigned IncrementSize = NVT.getSizeInBits() / 8; @@ -217,7 +219,8 @@ DAG.getIntPtrConstant(IncrementSize)); Hi = DAG.getLoad(NVT, dl, Chain, Ptr, LD->getSrcValue(), SVOffset+IncrementSize, - isVolatile, MinAlign(Alignment, IncrementSize)); + isVolatile, isNonTemporal, + MinAlign(Alignment, IncrementSize)); // Build a factor node to remember that this load is independent of the // other one. @@ -383,6 +386,7 @@ int SVOffset = St->getSrcValueOffset(); unsigned Alignment = St->getAlignment(); bool isVolatile = St->isVolatile(); + bool isNonTemporal = St->isNonTemporal(); assert(NVT.isByteSized() && "Expanded type not byte sized!"); unsigned IncrementSize = NVT.getSizeInBits() / 8; @@ -394,14 +398,15 @@ std::swap(Lo, Hi); Lo = DAG.getStore(Chain, dl, Lo, Ptr, St->getSrcValue(), SVOffset, - isVolatile, Alignment); + isVolatile, isNonTemporal, Alignment); Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, DAG.getIntPtrConstant(IncrementSize)); assert(isTypeLegal(Ptr.getValueType()) && "Pointers must be legal!"); Hi = DAG.getStore(Chain, dl, Hi, Ptr, St->getSrcValue(), SVOffset + IncrementSize, - isVolatile, MinAlign(Alignment, IncrementSize)); + isVolatile, isNonTemporal, + MinAlign(Alignment, IncrementSize)); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Lo, Hi); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Mon Feb 15 11:00:31 2010 @@ -172,7 +172,8 @@ DAG.getUNDEF(N->getBasePtr().getValueType()), N->getSrcValue(), N->getSrcValueOffset(), N->getMemoryVT().getVectorElementType(), - N->isVolatile(), N->getOriginalAlignment()); + N->isVolatile(), N->isNonTemporal(), + N->getOriginalAlignment()); // Legalized the chain result - switch anything that used the old chain to // use the new one. @@ -366,11 +367,13 @@ N->getBasePtr(), N->getSrcValue(), N->getSrcValueOffset(), N->getMemoryVT().getVectorElementType(), - N->isVolatile(), N->getAlignment()); + N->isVolatile(), N->isNonTemporal(), + N->getAlignment()); return DAG.getStore(N->getChain(), dl, GetScalarizedVector(N->getOperand(1)), N->getBasePtr(), N->getSrcValue(), N->getSrcValueOffset(), - N->isVolatile(), N->getOriginalAlignment()); + N->isVolatile(), N->isNonTemporal(), + N->getOriginalAlignment()); } @@ -696,17 +699,20 @@ EVT VecVT = Vec.getValueType(); EVT EltVT = VecVT.getVectorElementType(); SDValue StackPtr = DAG.CreateStackTemporary(VecVT); - SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, NULL, 0); + SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, NULL, 0, + false, false, 0); // Store the new element. This may be larger than the vector element type, // so use a truncating store. SDValue EltPtr = GetVectorElementPointer(StackPtr, EltVT, Idx); unsigned Alignment = TLI.getTargetData()->getPrefTypeAlignment(VecVT.getTypeForEVT(*DAG.getContext())); - Store = DAG.getTruncStore(Store, dl, Elt, EltPtr, NULL, 0, EltVT); + Store = DAG.getTruncStore(Store, dl, Elt, EltPtr, NULL, 0, EltVT, + false, false, 0); // Load the Lo part from the stack slot. - Lo = DAG.getLoad(Lo.getValueType(), dl, Store, StackPtr, NULL, 0); + Lo = DAG.getLoad(Lo.getValueType(), dl, Store, StackPtr, NULL, 0, + false, false, 0); // Increment the pointer to the other part. unsigned IncrementSize = Lo.getValueType().getSizeInBits() / 8; @@ -715,7 +721,7 @@ // Load the Hi part from the stack slot. Hi = DAG.getLoad(Hi.getValueType(), dl, Store, StackPtr, NULL, 0, false, - MinAlign(Alignment, IncrementSize)); + false, MinAlign(Alignment, IncrementSize)); } void DAGTypeLegalizer::SplitVecRes_SCALAR_TO_VECTOR(SDNode *N, SDValue &Lo, @@ -743,19 +749,20 @@ EVT MemoryVT = LD->getMemoryVT(); unsigned Alignment = LD->getOriginalAlignment(); bool isVolatile = LD->isVolatile(); + bool isNonTemporal = LD->isNonTemporal(); EVT LoMemVT, HiMemVT; GetSplitDestVTs(MemoryVT, LoMemVT, HiMemVT); Lo = DAG.getLoad(ISD::UNINDEXED, dl, ExtType, LoVT, Ch, Ptr, Offset, - SV, SVOffset, LoMemVT, isVolatile, Alignment); + SV, SVOffset, LoMemVT, isVolatile, isNonTemporal, Alignment); unsigned IncrementSize = LoMemVT.getSizeInBits()/8; Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, DAG.getIntPtrConstant(IncrementSize)); SVOffset += IncrementSize; Hi = DAG.getLoad(ISD::UNINDEXED, dl, ExtType, HiVT, Ch, Ptr, Offset, - SV, SVOffset, HiMemVT, isVolatile, Alignment); + SV, SVOffset, HiMemVT, isVolatile, isNonTemporal, Alignment); // Build a factor node to remember that this load is independent of the // other one. @@ -1086,12 +1093,13 @@ SDValue StackPtr = DAG.CreateStackTemporary(VecVT); int SPFI = cast(StackPtr.getNode())->getIndex(); const Value *SV = PseudoSourceValue::getFixedStack(SPFI); - SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, SV, 0); + SDValue Store = DAG.getStore(DAG.getEntryNode(), dl, Vec, StackPtr, SV, 0, + false, false, 0); // Load back the required element. StackPtr = GetVectorElementPointer(StackPtr, EltVT, Idx); return DAG.getExtLoad(ISD::EXTLOAD, dl, N->getValueType(0), Store, StackPtr, - SV, 0, EltVT); + SV, 0, EltVT, false, false, 0); } SDValue DAGTypeLegalizer::SplitVecOp_STORE(StoreSDNode *N, unsigned OpNo) { @@ -1106,6 +1114,7 @@ EVT MemoryVT = N->getMemoryVT(); unsigned Alignment = N->getOriginalAlignment(); bool isVol = N->isVolatile(); + bool isNT = N->isNonTemporal(); SDValue Lo, Hi; GetSplitVector(N->getOperand(1), Lo, Hi); @@ -1116,10 +1125,10 @@ if (isTruncating) Lo = DAG.getTruncStore(Ch, dl, Lo, Ptr, N->getSrcValue(), SVOffset, - LoMemVT, isVol, Alignment); + LoMemVT, isVol, isNT, Alignment); else Lo = DAG.getStore(Ch, dl, Lo, Ptr, N->getSrcValue(), SVOffset, - isVol, Alignment); + isVol, isNT, Alignment); // Increment the pointer to the other half. Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, @@ -1128,10 +1137,10 @@ if (isTruncating) Hi = DAG.getTruncStore(Ch, dl, Hi, Ptr, N->getSrcValue(), SVOffset, - HiMemVT, isVol, Alignment); + HiMemVT, isVol, isNT, Alignment); else Hi = DAG.getStore(Ch, dl, Hi, Ptr, N->getSrcValue(), SVOffset, - isVol, Alignment); + isVol, isNT, Alignment); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Lo, Hi); } @@ -2128,6 +2137,7 @@ int SVOffset = LD->getSrcValueOffset(); unsigned Align = LD->getAlignment(); bool isVolatile = LD->isVolatile(); + bool isNonTemporal = LD->isNonTemporal(); const Value *SV = LD->getSrcValue(); int LdWidth = LdVT.getSizeInBits(); @@ -2138,7 +2148,7 @@ EVT NewVT = FindMemType(DAG, TLI, LdWidth, WidenVT, LdAlign, WidthDiff); int NewVTWidth = NewVT.getSizeInBits(); SDValue LdOp = DAG.getLoad(NewVT, dl, Chain, BasePtr, SV, SVOffset, - isVolatile, Align); + isVolatile, isNonTemporal, Align); LdChain.push_back(LdOp.getValue(1)); // Check if we can load the element with one instruction @@ -2185,7 +2195,7 @@ SDValue LdOp = DAG.getLoad(NewVT, dl, Chain, BasePtr, SV, SVOffset+Offset, isVolatile, - MinAlign(Align, Increment)); + isNonTemporal, MinAlign(Align, Increment)); LdChain.push_back(LdOp.getValue(1)); LdOps.push_back(LdOp); @@ -2259,6 +2269,7 @@ int SVOffset = LD->getSrcValueOffset(); unsigned Align = LD->getAlignment(); bool isVolatile = LD->isVolatile(); + bool isNonTemporal = LD->isNonTemporal(); const Value *SV = LD->getSrcValue(); EVT EltVT = WidenVT.getVectorElementType(); @@ -2270,14 +2281,15 @@ SmallVector Ops(WidenNumElts); unsigned Increment = LdEltVT.getSizeInBits() / 8; Ops[0] = DAG.getExtLoad(ExtType, dl, EltVT, Chain, BasePtr, SV, SVOffset, - LdEltVT, isVolatile, Align); + LdEltVT, isVolatile, isNonTemporal, Align); LdChain.push_back(Ops[0].getValue(1)); unsigned i = 0, Offset = Increment; for (i=1; i < NumElts; ++i, Offset += Increment) { SDValue NewBasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(), BasePtr, DAG.getIntPtrConstant(Offset)); Ops[i] = DAG.getExtLoad(ExtType, dl, EltVT, Chain, NewBasePtr, SV, - SVOffset + Offset, LdEltVT, isVolatile, Align); + SVOffset + Offset, LdEltVT, isVolatile, + isNonTemporal, Align); LdChain.push_back(Ops[i].getValue(1)); } @@ -2301,6 +2313,7 @@ int SVOffset = ST->getSrcValueOffset(); unsigned Align = ST->getAlignment(); bool isVolatile = ST->isVolatile(); + bool isNonTemporal = ST->isNonTemporal(); SDValue ValOp = GetWidenedVector(ST->getValue()); DebugLoc dl = ST->getDebugLoc(); @@ -2326,6 +2339,7 @@ DAG.getIntPtrConstant(Idx)); StChain.push_back(DAG.getStore(Chain, dl, EOp, BasePtr, SV, SVOffset + Offset, isVolatile, + isNonTemporal, MinAlign(Align, Offset))); StWidth -= NewVTWidth; Offset += Increment; @@ -2344,8 +2358,8 @@ SDValue EOp = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NewVT, VecOp, DAG.getIntPtrConstant(Idx++)); StChain.push_back(DAG.getStore(Chain, dl, EOp, BasePtr, SV, - SVOffset + Offset, isVolatile, - MinAlign(Align, Offset))); + SVOffset + Offset, isVolatile, + isNonTemporal, MinAlign(Align, Offset))); StWidth -= NewVTWidth; Offset += Increment; BasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(), BasePtr, @@ -2368,6 +2382,7 @@ int SVOffset = ST->getSrcValueOffset(); unsigned Align = ST->getAlignment(); bool isVolatile = ST->isVolatile(); + bool isNonTemporal = ST->isNonTemporal(); SDValue ValOp = GetWidenedVector(ST->getValue()); DebugLoc dl = ST->getDebugLoc(); @@ -2390,7 +2405,7 @@ DAG.getIntPtrConstant(0)); StChain.push_back(DAG.getTruncStore(Chain, dl, EOp, BasePtr, SV, SVOffset, StEltVT, - isVolatile, Align)); + isVolatile, isNonTemporal, Align)); unsigned Offset = Increment; for (unsigned i=1; i < NumElts; ++i, Offset += Increment) { SDValue NewBasePtr = DAG.getNode(ISD::ADD, dl, BasePtr.getValueType(), @@ -2399,7 +2414,8 @@ DAG.getIntPtrConstant(0)); StChain.push_back(DAG.getTruncStore(Chain, dl, EOp, NewBasePtr, SV, SVOffset + Offset, StEltVT, - isVolatile, MinAlign(Align, Offset))); + isVolatile, isNonTemporal, + MinAlign(Align, Offset))); } } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Feb 15 11:00:31 2010 @@ -3299,7 +3299,7 @@ Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, DstAlign); + DstSV, DstSVOff + DstOff, false, false, DstAlign); } else { // The type might not be legal for the target. This should only happen // if the type is smaller than a legal type, as on PPC, so the right @@ -3310,10 +3310,11 @@ assert(NVT.bitsGE(VT)); Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, VT, false, Align); + SrcSV, SrcSVOff + SrcOff, VT, false, false, Align); Store = DAG.getTruncStore(Chain, dl, Value, - getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, VT, false, DstAlign); + getMemBasePlusOffset(Dst, DstOff, DAG), + DstSV, DstSVOff + DstOff, VT, false, false, + DstAlign); } OutChains.push_back(Store); SrcOff += VTSize; @@ -3358,7 +3359,7 @@ Value = DAG.getLoad(VT, dl, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, false, Align); + SrcSV, SrcSVOff + SrcOff, false, false, Align); LoadValues.push_back(Value); LoadChains.push_back(Value.getValue(1)); SrcOff += VTSize; @@ -3373,7 +3374,7 @@ Store = DAG.getStore(Chain, dl, LoadValues[i], getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, DstAlign); + DstSV, DstSVOff + DstOff, false, false, DstAlign); OutChains.push_back(Store); DstOff += VTSize; } @@ -3408,7 +3409,7 @@ SDValue Value = getMemsetValue(Src, VT, DAG, dl); SDValue Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff); + DstSV, DstSVOff + DstOff, false, false, 0); OutChains.push_back(Store); DstOff += VTSize; } @@ -3788,7 +3789,8 @@ ISD::LoadExtType ExtType, EVT VT, SDValue Chain, SDValue Ptr, SDValue Offset, const Value *SV, int SVOffset, EVT MemVT, - bool isVolatile, unsigned Alignment) { + bool isVolatile, bool isNonTemporal, + unsigned Alignment) { if (Alignment == 0) // Ensure that codegen never sees alignment 0 Alignment = getEVTAlignment(VT); @@ -3802,6 +3804,8 @@ unsigned Flags = MachineMemOperand::MOLoad; if (isVolatile) Flags |= MachineMemOperand::MOVolatile; + if (isNonTemporal) + Flags |= MachineMemOperand::MONonTemporal; MachineMemOperand *MMO = MF.getMachineMemOperand(SV, Flags, SVOffset, MemVT.getStoreSize(), Alignment); @@ -3856,20 +3860,22 @@ SDValue SelectionDAG::getLoad(EVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr, const Value *SV, int SVOffset, - bool isVolatile, unsigned Alignment) { + bool isVolatile, bool isNonTemporal, + unsigned Alignment) { SDValue Undef = getUNDEF(Ptr.getValueType()); return getLoad(ISD::UNINDEXED, dl, ISD::NON_EXTLOAD, VT, Chain, Ptr, Undef, - SV, SVOffset, VT, isVolatile, Alignment); + SV, SVOffset, VT, isVolatile, isNonTemporal, Alignment); } SDValue SelectionDAG::getExtLoad(ISD::LoadExtType ExtType, DebugLoc dl, EVT VT, SDValue Chain, SDValue Ptr, const Value *SV, int SVOffset, EVT MemVT, - bool isVolatile, unsigned Alignment) { + bool isVolatile, bool isNonTemporal, + unsigned Alignment) { SDValue Undef = getUNDEF(Ptr.getValueType()); return getLoad(ISD::UNINDEXED, dl, ExtType, VT, Chain, Ptr, Undef, - SV, SVOffset, MemVT, isVolatile, Alignment); + SV, SVOffset, MemVT, isVolatile, isNonTemporal, Alignment); } SDValue @@ -3881,12 +3887,13 @@ return getLoad(AM, dl, LD->getExtensionType(), OrigLoad.getValueType(), LD->getChain(), Base, Offset, LD->getSrcValue(), LD->getSrcValueOffset(), LD->getMemoryVT(), - LD->isVolatile(), LD->getAlignment()); + LD->isVolatile(), LD->isNonTemporal(), LD->getAlignment()); } SDValue SelectionDAG::getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, const Value *SV, int SVOffset, - bool isVolatile, unsigned Alignment) { + bool isVolatile, bool isNonTemporal, + unsigned Alignment) { if (Alignment == 0) // Ensure that codegen never sees alignment 0 Alignment = getEVTAlignment(Val.getValueType()); @@ -3900,6 +3907,8 @@ unsigned Flags = MachineMemOperand::MOStore; if (isVolatile) Flags |= MachineMemOperand::MOVolatile; + if (isNonTemporal) + Flags |= MachineMemOperand::MONonTemporal; MachineMemOperand *MMO = MF.getMachineMemOperand(SV, Flags, SVOffset, Val.getValueType().getStoreSize(), Alignment); @@ -3932,7 +3941,8 @@ SDValue SelectionDAG::getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, const Value *SV, int SVOffset, EVT SVT, - bool isVolatile, unsigned Alignment) { + bool isVolatile, bool isNonTemporal, + unsigned Alignment) { if (Alignment == 0) // Ensure that codegen never sees alignment 0 Alignment = getEVTAlignment(SVT); @@ -3946,6 +3956,8 @@ unsigned Flags = MachineMemOperand::MOStore; if (isVolatile) Flags |= MachineMemOperand::MOVolatile; + if (isNonTemporal) + Flags |= MachineMemOperand::MONonTemporal; MachineMemOperand *MMO = MF.getMachineMemOperand(SV, Flags, SVOffset, SVT.getStoreSize(), Alignment); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Feb 15 11:00:31 2010 @@ -844,7 +844,7 @@ Chains[i] = DAG.getStore(Chain, getCurDebugLoc(), SDValue(RetOp.getNode(), RetOp.getResNo() + i), - Add, NULL, Offsets[i], false, 0); + Add, NULL, Offsets[i], false, false, 0); } Chain = DAG.getNode(ISD::TokenFactor, getCurDebugLoc(), @@ -2705,7 +2705,9 @@ SDValue Ptr = getValue(SV); const Type *Ty = I.getType(); + bool isVolatile = I.isVolatile(); + bool isNonTemporal = I.getMetadata("nontemporal") != 0; unsigned Alignment = I.getAlignment(); SmallVector ValueVTs; @@ -2737,7 +2739,8 @@ PtrVT, Ptr, DAG.getConstant(Offsets[i], PtrVT)); SDValue L = DAG.getLoad(ValueVTs[i], getCurDebugLoc(), Root, - A, SV, Offsets[i], isVolatile, Alignment); + A, SV, Offsets[i], isVolatile, + isNonTemporal, Alignment); Values[i] = L; Chains[i] = L.getValue(1); @@ -2778,6 +2781,7 @@ SmallVector Chains(NumValues); EVT PtrVT = Ptr.getValueType(); bool isVolatile = I.isVolatile(); + bool isNonTemporal = I.getMetadata("nontemporal") != 0; unsigned Alignment = I.getAlignment(); for (unsigned i = 0; i != NumValues; ++i) { @@ -2785,7 +2789,8 @@ DAG.getConstant(Offsets[i], PtrVT)); Chains[i] = DAG.getStore(Root, getCurDebugLoc(), SDValue(Src.getNode(), Src.getResNo() + i), - Add, PtrV, Offsets[i], isVolatile, Alignment); + Add, PtrV, Offsets[i], isVolatile, + isNonTemporal, Alignment); } DAG.setRoot(DAG.getNode(ISD::TokenFactor, getCurDebugLoc(), @@ -4064,7 +4069,7 @@ // Store the stack protector onto the stack. Res = DAG.getStore(getRoot(), getCurDebugLoc(), Src, FIN, PseudoSourceValue::getFixedStack(FI), - 0, true); + 0, true, false, 0); setValue(&I, Res); DAG.setRoot(Res); return 0; @@ -4416,7 +4421,7 @@ DemoteStackSlot, DAG.getConstant(Offsets[i], PtrVT)); SDValue L = DAG.getLoad(OutVTs[i], getCurDebugLoc(), Result.second, - Add, NULL, Offsets[i], false, 1); + Add, NULL, Offsets[i], false, false, 1); Values[i] = L; Chains[i] = L.getValue(1); } @@ -4518,7 +4523,8 @@ SDValue Ptr = Builder.getValue(PtrVal); SDValue LoadVal = Builder.DAG.getLoad(LoadVT, Builder.getCurDebugLoc(), Root, Ptr, PtrVal /*SrcValue*/, 0/*SVOffset*/, - false /*volatile*/, 1 /* align=1 */); + false /*volatile*/, + false /*nontemporal*/, 1 /* align=1 */); if (!ConstantMemory) Builder.PendingLoads.push_back(LoadVal.getValue(1)); @@ -5336,7 +5342,8 @@ int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align, false); SDValue StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); Chain = DAG.getStore(Chain, getCurDebugLoc(), - OpInfo.CallOperand, StackSlot, NULL, 0); + OpInfo.CallOperand, StackSlot, NULL, 0, + false, false, 0); OpInfo.CallOperand = StackSlot; } @@ -5622,7 +5629,8 @@ SDValue Val = DAG.getStore(Chain, getCurDebugLoc(), StoresToEmit[i].first, getValue(StoresToEmit[i].second), - StoresToEmit[i].second, 0); + StoresToEmit[i].second, 0, + false, false, 0); OutChains.push_back(Val); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=96240&r1=96239&r2=96240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon Feb 15 11:00:31 2010 @@ -1716,7 +1716,7 @@ SDValue NewLoad = DAG.getLoad(newVT, dl, Lod->getChain(), Ptr, Lod->getSrcValue(), Lod->getSrcValueOffset() + bestOffset, - false, NewAlign); + false, false, NewAlign); return DAG.getSetCC(dl, VT, DAG.getNode(ISD::AND, dl, newVT, NewLoad, DAG.getConstant(bestMask.trunc(bestWidth), From greened at obbligato.org Mon Feb 15 11:02:57 2010 From: greened at obbligato.org (David Greene) Date: Mon, 15 Feb 2010 17:02:57 -0000 Subject: [llvm-commits] [llvm] r96241 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-02-11-NonTemporal.ll Message-ID: <201002151702.o1FH2vXL007197@zion.cs.uiuc.edu> Author: greened Date: Mon Feb 15 11:02:56 2010 New Revision: 96241 URL: http://llvm.org/viewvc/llvm-project?rev=96241&view=rev Log: Add support for emitting non-temporal stores for DAGs marked non-temporal. Added: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=96241&r1=96240&r2=96241&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Feb 15 11:02:56 2010 @@ -160,6 +160,32 @@ def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>; def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>; +// MOVNT Support +// Like 'store', but requires the non-temporal bit to be set +def nontemporalstore : PatFrag<(ops node:$val, node:$ptr), + (st node:$val, node:$ptr), [{ + if (StoreSDNode *ST = dyn_cast(N)) + return ST->isNonTemporal(); + return false; +}]>; + +def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), + (st node:$val, node:$ptr), [{ + if (StoreSDNode *ST = dyn_cast(N)) + return ST->isNonTemporal() && !ST->isTruncatingStore() && + ST->getAddressingMode() == ISD::UNINDEXED && + ST->getAlignment() >= 16; + return false; +}]>; + +def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), + (st node:$val, node:$ptr), [{ + if (StoreSDNode *ST = dyn_cast(N)) + return ST->isNonTemporal() && + ST->getAlignment() < 16; + return false; +}]>; + def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>; def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>; def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>; @@ -1013,10 +1039,33 @@ "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>; // Non-temporal stores -def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), +def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), "movntps\t{$src, $dst|$dst, $src}", [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>; +let AddedComplexity = 400 in { // Prefer non-temporal versions +def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntps\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; + +def MOVNTDQ_64mr : PSI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>; + +def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst), + (MOVNTDQ_64mr VR128:$src, addr:$dst)>; + +def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), + "movnti\t{$src, $dst|$dst, $src}", + [(nontemporalstore (i32 GR32:$src), addr:$dst)]>, + TB, Requires<[HasSSE2]>; + +def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), + "movnti\t{$src, $dst|$dst, $src}", + [(nontemporalstore (i64 GR64:$src), addr:$dst)]>, + TB, Requires<[HasSSE2]>; +} + // Load, store, and memory fence def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>; @@ -2298,17 +2347,30 @@ [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>; // Non-temporal stores -def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; -def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; -def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), +def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), + "movntpd\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; +def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; +def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), "movnti\t{$src, $dst|$dst, $src}", [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>, TB, Requires<[HasSSE2]>; +let AddedComplexity = 400 in { // Prefer non-temporal versions +def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntpd\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>; + +def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; + +def : Pat<(alignednontemporalstore (v4i32 VR128:$src), addr:$dst), + (MOVNTDQmr VR128:$src, addr:$dst)>; +} + // Flush cache def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src), "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>, Added: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll?rev=96241&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Mon Feb 15 11:02:56 2010 @@ -0,0 +1,84 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s +; CHECK: movnt +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + at blk_ = linkonce global [700000 x i64] zeroinitializer, align 64 ; <[700000 x i64]*> [#uses=3] + at _dm_my_pe = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] + at _dm_pes_in_prog = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] + at _dm_npes_div_mult = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] + at _dm_npes_div_shift = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] + at _dm_pe_addr_loc = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] + at _dm_offset_addr_mask = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] + +!0 = metadata !{ i32 1 } + +define void @sub_(i32* noalias %n) { +"file movnt.f90, line 2, bb1": ; srcLine 2 + %n1 = alloca i32*, align 8 ; [#uses=1] ; [oox.12 : sln.2] + %i = alloca i32, align 4 ; [#uses=0] ; [oox.14 : sln.2] + %"$LIS_E0" = alloca i64, align 8 ; [#uses=2] ; [oox.72 : sln.2] + %"$LCS_0" = alloca i64, align 8 ; [#uses=7] ; [oox.73 : sln.2] + %"$SI_S1" = alloca i64, align 8 ; [#uses=4] ; [oox.75 : sln.2] + %"$LCS_S2" = alloca <2 x double>, align 16 ; <<2 x double>*> [#uses=6] ; [oox.76 : sln.2] + %"$LC_S3" = alloca i64, align 8 ; [#uses=4] ; [oox.77 : sln.2] + volatile store i32* %n, i32** %n1 ; [oox.12 : sln.2] + br label %"file movnt.f90, line 2, bb32" ; [oox.0 : sln.0] + +"file movnt.f90, line 2, bb32": ; srcLine 2 ; preds = %"file movnt.f90, line 2, bb1" + store i64 -50000, i64* %"$LC_S3", align 8 ; [oox.160 : sln.10] + store i64 0, i64* %"$SI_S1", align 8 ; [oox.161 : sln.10] + store i64 ptrtoint ([700000 x i64]* @blk_ to i64), i64* %"$LIS_E0", align 8 ; [oox.162 : sln.11] + br label %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25" ; [oox.0 : sln.0] + +"file movnt.f90, line 2, in inner vector loop at depth 0, bb25": ; srcLine 2 ; preds = %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23", %"file movnt.f90, line 2, bb32" + br label %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23" ; [oox.0 : sln.0] + +"file movnt.f90, line 11, in inner vector loop at depth 0, bb23": ; srcLine 11 ; preds = %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25" + %r = load i64* %"$LIS_E0", align 8 ; [#uses=1] ; [oox.159 : sln.11] + %r2 = load i64* %"$SI_S1", align 8 ; [#uses=1] ; [oox.159 : sln.11] + %r3 = add i64 %r, %r2 ; [#uses=1] ; [oox.159 : sln.11] + store i64 %r3, i64* %"$LCS_0", align 8 ; [oox.159 : sln.11] + %r4 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.160 : sln.11] + %r5 = add i64 4000000, %r4 ; [#uses=1] ; [oox.160 : sln.11] + %r6 = inttoptr i64 %r5 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.160 : sln.11] + %r8 = load <2 x double>* %r6, align 16, !nontemporal !0 ; <<2 x double>> [#uses=1] ; [oox.160 : sln.11] + store <2 x double> %r8, <2 x double>* %"$LCS_S2", align 8 ; [oox.160 : sln.11] + %r9 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.161 : sln.11] + %r10 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.161 : sln.11] + %r11 = inttoptr i64 %r10 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.161 : sln.11] + store <2 x double> %r9, <2 x double>* %r11, align 16, !nontemporal !0 ; [oox.161 : sln.11] + %r13 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.162 : sln.12] + %r14 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.162 : sln.12] + %r15 = add i64 800000, %r14 ; [#uses=1] ; [oox.162 : sln.12] + %r16 = inttoptr i64 %r15 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.162 : sln.12] + store <2 x double> %r13, <2 x double>* %r16, align 16, !nontemporal !0 ; [oox.162 : sln.12] + %r18 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.163 : sln.13] + %r19 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.163 : sln.13] + %r20 = add i64 1600000, %r19 ; [#uses=1] ; [oox.163 : sln.13] + %r21 = inttoptr i64 %r20 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.163 : sln.13] + store <2 x double> %r18, <2 x double>* %r21, align 16, !nontemporal !0 ; [oox.163 : sln.13] + %r23 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.164 : sln.14] + %r24 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.164 : sln.14] + %r25 = add i64 2400000, %r24 ; [#uses=1] ; [oox.164 : sln.14] + %r26 = inttoptr i64 %r25 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.164 : sln.14] + store <2 x double> %r23, <2 x double>* %r26, align 16, !nontemporal !0 ; [oox.164 : sln.14] + %r28 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.165 : sln.15] + %r29 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.165 : sln.15] + %r30 = add i64 3200000, %r29 ; [#uses=1] ; [oox.165 : sln.15] + %r31 = inttoptr i64 %r30 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.165 : sln.15] + store <2 x double> %r28, <2 x double>* %r31, align 16, !nontemporal !0 ; [oox.165 : sln.15] + %r33 = load i64* %"$SI_S1", align 8 ; [#uses=1] ; [oox.166 : sln.10] + %r34 = add i64 16, %r33 ; [#uses=1] ; [oox.166 : sln.10] + store i64 %r34, i64* %"$SI_S1", align 8 ; [oox.166 : sln.10] + %r35 = load i64* %"$LC_S3", align 8 ; [#uses=1] ; [oox.167 : sln.10] + %r36 = add i64 1, %r35 ; [#uses=1] ; [oox.167 : sln.10] + store i64 %r36, i64* %"$LC_S3", align 8 ; [oox.167 : sln.10] + %r37 = load i64* %"$LC_S3", align 8 ; [#uses=1] ; [oox.168 : sln.10] + %r38 = icmp slt i64 %r37, 0 ; [#uses=1] ; [oox.168 : sln.10] + %r39 = zext i1 %r38 to i64 ; [#uses=1] ; [oox.168 : sln.10] + %r40 = icmp ne i64 %r39, 0 ; [#uses=1] ; [oox.168 : sln.10] + br i1 %r40, label %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25", label %"file movnt.f90, line 18, bb5" ; [oox.168 : sln.10] + +"file movnt.f90, line 18, bb5": ; srcLine 18 ; preds = %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23" + ret void ; [oox.159 : sln.18] +} From daniel at zuster.org Mon Feb 15 11:13:12 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 15 Feb 2010 09:13:12 -0800 Subject: [llvm-commits] [llvm] r96226 - in /llvm/trunk: include/llvm/CodeGen/MachineMemOperand.h lib/CodeGen/MachineInstr.cpp In-Reply-To: <201002151648.o1FGmVvL006149@zion.cs.uiuc.edu> References: <201002151648.o1FGmVvL006149@zion.cs.uiuc.edu> Message-ID: <6a8523d61002150913n7b1178c1q7de9bc53eac563@mail.gmail.com> As a friendly reminder, for those using git and friends, please do not use the ability to batch commits as an excuse not to build and test every individual commit. Doing so breaks important things like the buildbots and the ability to easily bisect or test every revision. - Daniel On Mon, Feb 15, 2010 at 8:48 AM, David Greene wrote: > Author: greened > Date: Mon Feb 15 10:48:31 2010 > New Revision: 96226 > > URL: http://llvm.org/viewvc/llvm-project?rev=96226&view=rev > Log: > > Add non-temporal flags to MachineMemOperand. > > Modified: > ? ?llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h > ? ?llvm/trunk/lib/CodeGen/MachineInstr.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h?rev=96226&r1=96225&r2=96226&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h (original) > +++ llvm/trunk/include/llvm/CodeGen/MachineMemOperand.h Mon Feb 15 10:48:31 2010 > @@ -46,7 +46,11 @@ > ? ? /// The memory access writes data. > ? ? MOStore = 2, > ? ? /// The memory access is volatile. > - ? ?MOVolatile = 4 > + ? ?MOVolatile = 4, > + ? ?/// The memory access is non-temporal. > + ? ?MONonTemporal = 8, > + ? ?// This is the number of bits we need to represent flags. > + ? ?MOMaxBits = 4 > ? }; > > ? /// MachineMemOperand - Construct an MachineMemOperand object with the > @@ -64,7 +68,7 @@ > ? const Value *getValue() const { return V; } > > ? /// getFlags - Return the raw flags of the source value, \see MemOperandFlags. > - ?unsigned int getFlags() const { return Flags & 7; } > + ?unsigned int getFlags() const { return Flags & ((1 << MOMaxBits) - 1); } > > ? /// getOffset - For normal values, this is a byte offset added to the base > ? /// address. For PseudoSourceValue::FPRel values, this is the FrameIndex > @@ -80,11 +84,12 @@ > > ? /// getBaseAlignment - Return the minimum known alignment in bytes of the > ? /// base address, without the offset. > - ?uint64_t getBaseAlignment() const { return (1u << (Flags >> 3)) >> 1; } > + ?uint64_t getBaseAlignment() const { return (1u << (Flags >> MOMaxBits)) >> 1; } > > ? bool isLoad() const { return Flags & MOLoad; } > ? bool isStore() const { return Flags & MOStore; } > ? bool isVolatile() const { return Flags & MOVolatile; } > + ?bool isNonTemporal() const { return Flags & MONonTemporal; } > > ? /// refineAlignment - Update this MachineMemOperand to reflect the alignment > ? /// of MMO, if it has a greater alignment. This must only be used when the > > Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=96226&r1=96225&r2=96226&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Feb 15 10:48:31 2010 > @@ -305,7 +305,7 @@ > ?MachineMemOperand::MachineMemOperand(const Value *v, unsigned int f, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?int64_t o, uint64_t s, unsigned int a) > ? : Offset(o), Size(s), V(v), > - ? ?Flags((f & 7) | ((Log2_32(a) + 1) << 3)) { > + ? ?Flags((f & ((1 << MOMaxBits) - 1)) | ((Log2_32(a) + 1) << MOMaxBits)) { > ? assert(getBaseAlignment() == a && "Alignment is not a power of 2!"); > ? assert((isLoad() || isStore()) && "Not a load/store!"); > ?} > @@ -327,7 +327,8 @@ > > ? if (MMO->getBaseAlignment() >= getBaseAlignment()) { > ? ? // Update the alignment value. > - ? ?Flags = (Flags & 7) | ((Log2_32(MMO->getBaseAlignment()) + 1) << 3); > + ? ?Flags = (Flags & ((1 << MOMaxBits) - 1)) | > + ? ? ?((Log2_32(MMO->getBaseAlignment()) + 1) << MOMaxBits); > ? ? // Also update the base and offset, because the new alignment may > ? ? // not be applicable with the old ones. > ? ? V = MMO->getValue(); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gohman at apple.com Mon Feb 15 11:21:49 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Feb 2010 09:21:49 -0800 Subject: [llvm-commits] [llvm] r96214 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h In-Reply-To: <201002150711.o1F7BZiY028560@zion.cs.uiuc.edu> References: <201002150711.o1F7BZiY028560@zion.cs.uiuc.edu> Message-ID: <176E4A09-7C1B-4831-8926-C11DFB56B69A@apple.com> On Feb 14, 2010, at 11:11 PM, Chris Lattner wrote: > Author: lattner > Date: Mon Feb 15 01:11:34 2010 > New Revision: 96214 > > URL: http://llvm.org/viewvc/llvm-project?rev=96214&view=rev > Log: > give SDValue an operator->, allowing V->isTargetOpcode() and > many other natural things. I had been gradually moving everything away from using SDValues as if they were SDNodes. While it's convenient to ignore the distinction sometimes, it's really hard to follow when it does matter. Dan From gohman at apple.com Mon Feb 15 11:27:50 2010 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Feb 2010 09:27:50 -0800 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> Message-ID: <0E341BE8-60FA-47CB-99B7-3F1301AC1ADA@apple.com> On Feb 13, 2010, at 9:36 AM, nicolas geoffray wrote: > Hi Dan, > > On Fri, Feb 12, 2010 at 11:34 AM, Dan Gohman wrote: > ============================================================================== > --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) > +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Feb 12 04:34:29 2010 > @@ -234,6 +235,9 @@ > PM.add(createLoopStrengthReducePass(getTargetLowering())); > if (PrintLSR) > PM.add(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &dbgs())); > +#ifndef NDEBUG > + PM.add(createVerifierPass()); > +#endif > } > > > Could you remove that change? This turns on a verifier for all builds except when DISABLE_ASSERTIONS is set. I'd like to have debug/release builds without the verifier running. Having that verifier run is very useful. Getting all defs before their uses is one of the trickiest parts of LSR; the old one didn't always get it right, and the new one is finding it challenging as well. And it's much easier to diagnose a verifier failure than a silent miscompile. Maybe we can put the verifier run under the control of an option, so it can be disabled. Would a command-line option be usable for you? Dan From daniel at zuster.org Mon Feb 15 11:33:20 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 15 Feb 2010 09:33:20 -0800 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: <0E341BE8-60FA-47CB-99B7-3F1301AC1ADA@apple.com> References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> <0E341BE8-60FA-47CB-99B7-3F1301AC1ADA@apple.com> Message-ID: <6a8523d61002150933h385d414du39e45901666824c@mail.gmail.com> Please do not add more command line options to the backend. I think it should be up to the front-ends whether or not they want this verifier pass. What about moving this code to llvm-backend.cpp (llvm-gcc) and Backend.cpp (clang). - Daniel On Mon, Feb 15, 2010 at 9:27 AM, Dan Gohman wrote: > > On Feb 13, 2010, at 9:36 AM, nicolas geoffray wrote: > >> Hi Dan, >> >> On Fri, Feb 12, 2010 at 11:34 AM, Dan Gohman wrote: >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) >> +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Feb 12 04:34:29 2010 >> @@ -234,6 +235,9 @@ >> ? ? PM.add(createLoopStrengthReducePass(getTargetLowering())); >> ? ? if (PrintLSR) >> ? ? ? PM.add(createPrintFunctionPass("\n\n*** Code after LSR ***\n", &dbgs())); >> +#ifndef NDEBUG >> + ? ?PM.add(createVerifierPass()); >> +#endif >> ? } >> >> >> Could you remove that change? This turns on a verifier for all builds except when DISABLE_ASSERTIONS is set. I'd like to have debug/release builds without the verifier running. > > Having that verifier run is very useful. Getting all defs before their uses > is one of the trickiest parts of LSR; the old one didn't always get it > right, and the new one is finding it challenging as well. And it's much > easier to diagnose a verifier failure than a silent miscompile. > Maybe we can put the verifier run under the control of an option, so it > can be disabled. Would a command-line option be usable for you? > > Dan > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dag at cray.com Mon Feb 15 11:38:36 2010 From: dag at cray.com (David Greene) Date: Mon, 15 Feb 2010 11:38:36 -0600 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: <6a8523d61002150933h385d414du39e45901666824c@mail.gmail.com> References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> <0E341BE8-60FA-47CB-99B7-3F1301AC1ADA@apple.com> <6a8523d61002150933h385d414du39e45901666824c@mail.gmail.com> Message-ID: <201002151138.37172.dag@cray.com> On Monday 15 February 2010 11:33:20 Daniel Dunbar wrote: > Please do not add more command line options to the backend. > > I think it should be up to the front-ends whether or not they want > this verifier pass. What about moving this code to llvm-backend.cpp > (llvm-gcc) and Backend.cpp (clang). The verifier has saved me many times. I would hate to move this call out of LLVM proper. We've found many problems with LSR in the past. Perhaps Nicolas can describe his use-case and we can find a solution that works for everyone. -Dave From daniel at zuster.org Mon Feb 15 11:47:02 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 15 Feb 2010 09:47:02 -0800 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: <201002151138.37172.dag@cray.com> References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> <0E341BE8-60FA-47CB-99B7-3F1301AC1ADA@apple.com> <6a8523d61002150933h385d414du39e45901666824c@mail.gmail.com> <201002151138.37172.dag@cray.com> Message-ID: <6a8523d61002150947gff763eflfe7bdd4069502c9e@mail.gmail.com> On Mon, Feb 15, 2010 at 9:38 AM, David Greene wrote: > On Monday 15 February 2010 11:33:20 Daniel Dunbar wrote: >> Please do not add more command line options to the backend. >> >> I think it should be up to the front-ends whether or not they want >> this verifier pass. What about moving this code to llvm-backend.cpp >> (llvm-gcc) and Backend.cpp (clang). > > The verifier has saved me many times. ?I would hate to move this call out of > LLVM proper. ?We've found many problems with LSR in the past. ?Perhaps Nicolas > can describe his use-case and we can find a solution that works for everyone. You are free to add as many verifier passes as you want, I didn't suggest removing it, I merely suggested making it a client decision. Libraries shouldn't impose policy decisions on their clients. - Daniel > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? -Dave > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From baldrick at free.fr Mon Feb 15 12:01:44 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Feb 2010 18:01:44 -0000 Subject: [llvm-commits] [dragonegg] r96243 - in /dragonegg/trunk: llvm-abi-default.cpp llvm-backend.cpp llvm-convert.cpp llvm-types.cpp x86/llvm-target.cpp Message-ID: <201002151801.o1FI1jP8010162@zion.cs.uiuc.edu> Author: baldrick Date: Mon Feb 15 12:01:44 2010 New Revision: 96243 URL: http://llvm.org/viewvc/llvm-project?rev=96243&view=rev Log: Uniformize the names of type predicates: rather than having isFloatTy and isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! Modified: dragonegg/trunk/llvm-abi-default.cpp dragonegg/trunk/llvm-backend.cpp dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-types.cpp dragonegg/trunk/x86/llvm-target.cpp Modified: dragonegg/trunk/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi-default.cpp?rev=96243&r1=96242&r2=96243&view=diff ============================================================================== --- dragonegg/trunk/llvm-abi-default.cpp (original) +++ dragonegg/trunk/llvm-abi-default.cpp Mon Feb 15 12:01:44 2010 @@ -324,7 +324,7 @@ if (InSize < Size) { unsigned N = STy->getNumElements(); const llvm::Type *LastEltTy = STy->getElementType(N-1); - if (LastEltTy->isInteger()) + if (LastEltTy->isIntegerTy()) LastEltSizeDiff = getTargetData().getTypeAllocSize(LastEltTy) - (Size - InSize); } Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=96243&r1=96242&r2=96243&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Mon Feb 15 12:01:44 2010 @@ -1686,7 +1686,7 @@ } // Covariant return thunk - adjust the returned value by the thunk offsets. - assert(Call->getType()->isPointer() && "Only know how to adjust pointers!"); + assert(Call->getType()->isPointerTy() && "Only know how to adjust pointers!"); Value *RetVal = Call; // First check if the returned value is NULL. Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=96243&r1=96242&r2=96243&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Mon Feb 15 12:01:44 2010 @@ -455,7 +455,7 @@ // If this is just a mismatch between integer types, this is due // to K&R prototypes, where the forward proto defines the arg as int // and the actual impls is a short or char. - assert(ArgVal->getType()->isInteger(32) && LLVMTy->isInteger() && + assert(ArgVal->getType()->isIntegerTy(32) && LLVMTy->isIntegerTy() && "Lowerings don't match?"); ArgVal = Builder.CreateTrunc(ArgVal, LLVMTy,NameStack.back().c_str()); } @@ -1501,14 +1501,14 @@ /// contains any floating point elements. static bool containsFPField(const Type *LLVMTy) { - if (LLVMTy->isFloatingPoint()) + if (LLVMTy->isFloatingPointTy()) return true; const StructType* STy = dyn_cast(LLVMTy); if (STy) { for (StructType::element_iterator I = STy->element_begin(), E = STy->element_end(); I != E; I++) { const Type *Ty = *I; - if (Ty->isFloatingPoint()) + if (Ty->isFloatingPointTy()) return true; if (isa(Ty) && containsFPField(Ty)) return true; @@ -2178,7 +2178,7 @@ // The number of loads needed to read the entire bitfield. unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; - assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); + assert(ValTy->isIntegerTy() && "Invalid bitfield lvalue!"); assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); @@ -4809,7 +4809,7 @@ Value *Offset = EmitMemory(gimple_call_arg(stmt, 0)); Value *Handler = EmitMemory(gimple_call_arg(stmt, 1)); - Intrinsic::ID IID = IntPtr->isInteger(32) ? + Intrinsic::ID IID = IntPtr->isIntegerTy(32) ? Intrinsic::eh_return_i32 : Intrinsic::eh_return_i64; Offset = Builder.CreateIntCast(Offset, IntPtr, /*isSigned*/true); @@ -5395,7 +5395,7 @@ if (isBitfield(FieldDecl)) { // If this is a bitfield, the declared type must be an integral type. - assert(FieldTy->isInteger() && "Invalid bitfield"); + assert(FieldTy->isIntegerTy() && "Invalid bitfield"); assert(DECL_SIZE(FieldDecl) && TREE_CODE(DECL_SIZE(FieldDecl)) == INTEGER_CST && @@ -5410,7 +5410,7 @@ // things that are difficult to clean up later. This occurs in cases like // "struct X{ unsigned long long x:50; unsigned y:2; }" when accessing y. // We want to access the field as a ulong, not as a uint with an offset. - if (LLVMFieldTy->isInteger() && + if (LLVMFieldTy->isIntegerTy() && LLVMFieldTy->getPrimitiveSizeInBits() >= BitStart + BitfieldSize && LLVMFieldTy->getPrimitiveSizeInBits() == TD.getTypeAllocSizeInBits(LLVMFieldTy)) @@ -5689,7 +5689,7 @@ if (MemTy == RegTy) return V; - assert(RegTy->isInteger() && MemTy->isInteger() && + assert(RegTy->isIntegerTy() && MemTy->isIntegerTy() && "Unexpected type mismatch!"); return Builder.CreateIntCast(V, RegTy, /*isSigned*/!TYPE_UNSIGNED(type)); } @@ -5702,7 +5702,7 @@ if (MemTy == RegTy) return C; - assert(RegTy->isInteger() && MemTy->isInteger() && + assert(RegTy->isIntegerTy() && MemTy->isIntegerTy() && "Unexpected type mismatch!"); return Folder.CreateIntCast(C, RegTy, /*isSigned*/!TYPE_UNSIGNED(type)); } @@ -5717,7 +5717,7 @@ if (RegTy == MemTy) return V; - assert(RegTy->isInteger() && MemTy->isInteger() && + assert(RegTy->isIntegerTy() && MemTy->isIntegerTy() && "Unexpected type mismatch!"); return Builder.CreateIntCast(V, MemTy, /*isSigned*/!TYPE_UNSIGNED(type)); } @@ -5842,7 +5842,7 @@ // Unary expressions. Value *TreeToLLVM::EmitReg_ABS_EXPR(tree op) { Value *Op = EmitRegister(op); - if (!Op->getType()->isFloatingPoint()) { + if (!Op->getType()->isFloatingPointTy()) { Value *OpN = Builder.CreateNeg(Op, Op->getName()+"neg"); ICmpInst::Predicate pred = TYPE_UNSIGNED(TREE_TYPE(op)) ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_SGE; @@ -5917,7 +5917,7 @@ Value *TreeToLLVM::EmitReg_TRUTH_NOT_EXPR(tree type, tree op) { Value *V = EmitRegister(op); - if (!V->getType()->isInteger(1)) + if (!V->getType()->isIntegerTy(1)) V = Builder.CreateICmpNE(V, Constant::getNullValue(V->getType()), "toBool"); V = Builder.CreateNot(V, V->getName()+"not"); @@ -5985,7 +5985,7 @@ SplitComplex(RHS, RHSr, RHSi, TREE_TYPE(TREE_TYPE(lhs))); Value *DSTr, *DSTi; - if (LHSr->getType()->isFloatingPoint()) { + if (LHSr->getType()->isFloatingPointTy()) { DSTr = Builder.CreateFCmp(FPPred, LHSr, RHSr); DSTi = Builder.CreateFCmp(FPPred, LHSi, RHSi); if (FPPred == CmpInst::FCMP_OEQ) @@ -6003,7 +6003,7 @@ return Builder.CreateOr(DSTr, DSTi); } - if (LHS->getType()->isFPOrFPVector()) + if (LHS->getType()->isFPOrFPVectorTy()) return Builder.CreateFCmp(FPPred, LHS, RHS); // Determine which predicate to use based on signedness. @@ -6032,7 +6032,7 @@ RHS = Builder.CreateCast(opcode, RHS, Ty); Value *Compare; - if (LHS->getType()->isFloatingPoint()) + if (LHS->getType()->isFloatingPointTy()) Compare = Builder.CreateFCmp(FCmpInst::Predicate(FPPred), LHS, RHS); else if (TYPE_UNSIGNED(type)) Compare = Builder.CreateICmp(ICmpInst::Predicate(UIPred), LHS, RHS); @@ -6479,7 +6479,7 @@ Value *DSTr, *DSTi; // (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) - assert (LHSr->getType()->isInteger() && "TRUNC_DIV_EXPR not integer!"); + assert (LHSr->getType()->isIntegerTy() && "TRUNC_DIV_EXPR not integer!"); // If overflow does not wrap in the element type then it is tempting to // use NSW operations here. However that would be wrong since overflow // of an intermediate value calculated here does not necessarily imply @@ -6503,7 +6503,7 @@ return CreateComplex(DSTr, DSTi, elt_type); } - assert(LHS->getType()->isIntOrIntVector() && "TRUNC_DIV_EXPR not integer!"); + assert(LHS->getType()->isIntOrIntVectorTy() && "TRUNC_DIV_EXPR not integer!"); if (TYPE_UNSIGNED(type)) { // if (isExact) // return Builder.CreateExactUDiv(LHS, RHS); @@ -7430,7 +7430,7 @@ // The number of stores needed to write the entire bitfield. unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; - assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); + assert(ValTy->isIntegerTy() && "Invalid bitfield lvalue!"); assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); @@ -7552,7 +7552,7 @@ Constant *TreeConstantToLLVM::ConvertREAL_CST(tree exp) { const Type *Ty = ConvertType(TREE_TYPE(exp)); - assert(Ty->isFloatingPoint() && "Integer REAL_CST?"); + assert(Ty->isFloatingPointTy() && "Integer REAL_CST?"); long RealArr[2]; union { int UArr[2]; @@ -7634,11 +7634,11 @@ unsigned Len = (unsigned)TREE_STRING_LENGTH(exp); std::vector Elts; - if (ElTy->isInteger(8)) { + if (ElTy->isIntegerTy(8)) { const unsigned char *InStr =(const unsigned char *)TREE_STRING_POINTER(exp); for (unsigned i = 0; i != Len; ++i) Elts.push_back(ConstantInt::get(Type::getInt8Ty(Context), InStr[i])); - } else if (ElTy->isInteger(16)) { + } else if (ElTy->isIntegerTy(16)) { assert((Len&1) == 0 && "Length in bytes should be a multiple of element size"); const uint16_t *InStr = @@ -7650,9 +7650,10 @@ if (llvm::sys::isBigEndianHost() == BYTES_BIG_ENDIAN) Elts.push_back(ConstantInt::get(Type::getInt16Ty(Context), InStr[i])); else - Elts.push_back(ConstantInt::get(Type::getInt16Ty(Context), ByteSwap_16(InStr[i]))); + Elts.push_back(ConstantInt::get(Type::getInt16Ty(Context), + ByteSwap_16(InStr[i]))); } - } else if (ElTy->isInteger(32)) { + } else if (ElTy->isIntegerTy(32)) { assert((Len&3) == 0 && "Length in bytes should be a multiple of element size"); const uint32_t *InStr = (const uint32_t *)TREE_STRING_POINTER(exp); @@ -7663,7 +7664,8 @@ if (llvm::sys::isBigEndianHost() == BYTES_BIG_ENDIAN) Elts.push_back(ConstantInt::get(Type::getInt32Ty(Context), InStr[i])); else - Elts.push_back(ConstantInt::get(Type::getInt32Ty(Context), ByteSwap_32(InStr[i]))); + Elts.push_back(ConstantInt::get(Type::getInt32Ty(Context), + ByteSwap_32(InStr[i]))); } } else { assert(0 && "Unknown character type!"); @@ -8118,7 +8120,7 @@ if (GCCFieldOffsetInBits < NextFieldByteStart*8) { unsigned ValBitSize = ValC->getBitWidth(); assert(!ResultElts.empty() && "Bitfield starts before first element?"); - assert(ResultElts.back()->getType()->isInteger(8) && + assert(ResultElts.back()->getType()->isIntegerTy(8) && isa(ResultElts.back()) && "Merging bitfield with non-bitfield value?"); assert(NextFieldByteStart*8 - GCCFieldOffsetInBits < 8 && Modified: dragonegg/trunk/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=96243&r1=96242&r2=96243&view=diff ============================================================================== --- dragonegg/trunk/llvm-types.cpp (original) +++ dragonegg/trunk/llvm-types.cpp Mon Feb 15 12:01:44 2010 @@ -943,8 +943,8 @@ if (KNRPromotion) { if (type == float_type_node) LLVMTy = ConvertType(double_type_node); - else if (LLVMTy->isInteger(16) || LLVMTy->isInteger(8) || - LLVMTy->isInteger(1)) + else if (LLVMTy->isIntegerTy(16) || LLVMTy->isIntegerTy(8) || + LLVMTy->isIntegerTy(1)) LLVMTy = Type::getInt32Ty(Context); } ArgTypes.push_back(LLVMTy); @@ -1345,13 +1345,13 @@ const Type *LastType = Elements.back(); unsigned PadBytes = 0; - if (LastType->isInteger(8)) + if (LastType->isIntegerTy(8)) PadBytes = 1 - NoOfBytesToRemove; - else if (LastType->isInteger(16)) + else if (LastType->isIntegerTy(16)) PadBytes = 2 - NoOfBytesToRemove; - else if (LastType->isInteger(32)) + else if (LastType->isIntegerTy(32)) PadBytes = 4 - NoOfBytesToRemove; - else if (LastType->isInteger(64)) + else if (LastType->isIntegerTy(64)) PadBytes = 8 - NoOfBytesToRemove; else return; Modified: dragonegg/trunk/x86/llvm-target.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/x86/llvm-target.cpp?rev=96243&r1=96242&r2=96243&view=diff ============================================================================== --- dragonegg/trunk/x86/llvm-target.cpp (original) +++ dragonegg/trunk/x86/llvm-target.cpp Mon Feb 15 12:01:44 2010 @@ -1296,7 +1296,7 @@ for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) { const Type *STy = I->get(); - if (!STy->isIntOrIntVector() && !isa(STy)) + if (!STy->isIntOrIntVectorTy() && !isa(STy)) return false; } return true; @@ -1359,10 +1359,10 @@ // makes it ABI compatible for x86-64. Same for _Complex char and _Complex // short in 32-bit. const Type *EltTy = STy->getElementType(0); - return !((TARGET_64BIT && (EltTy->isInteger() || + return !((TARGET_64BIT && (EltTy->isIntegerTy() || EltTy == Type::getFloatTy(Context) || EltTy == Type::getDoubleTy(Context))) || - EltTy->isInteger(16) || EltTy->isInteger(8)); + EltTy->isIntegerTy(16) || EltTy->isIntegerTy(8)); } /* Target hook for llvm-abi.h. It returns true if an aggregate of the @@ -1401,14 +1401,14 @@ else // All other vector scalar values are passed in XMM registers. ++NumXMMs; - } else if (Ty->isInteger() || isa(Ty)) { + } else if (Ty->isIntegerTy() || isa(Ty)) { ++NumGPRs; } else if (Ty==Type::getVoidTy(Context)) { // Padding bytes that are not passed anywhere ; } else { // Floating point scalar argument. - assert(Ty->isFloatingPoint() && Ty->isPrimitiveType() && + assert(Ty->isFloatingPointTy() && Ty->isPrimitiveType() && "Expecting a floating point primitive type!"); if (Ty->getTypeID() == Type::FloatTyID || Ty->getTypeID() == Type::DoubleTyID) @@ -1522,7 +1522,7 @@ Ty = STy->getElementType(0); if (const VectorType *VTy = dyn_cast(Ty)) { if (VTy->getNumElements() == 2) { - if (VTy->getElementType()->isInteger()) { + if (VTy->getElementType()->isIntegerTy()) { Elts.push_back(VectorType::get(Type::getInt64Ty(Context), 2)); } else { Elts.push_back(VectorType::get(Type::getDoubleTy(Context), 2)); @@ -1530,7 +1530,7 @@ Bytes -= 8; } else { assert(VTy->getNumElements() == 4); - if (VTy->getElementType()->isInteger()) { + if (VTy->getElementType()->isIntegerTy()) { Elts.push_back(VectorType::get(Type::getInt32Ty(Context), 4)); } else { Elts.push_back(VectorType::get(Type::getFloatTy(Context), 4)); @@ -1886,14 +1886,14 @@ Ty = STy->getElementType(0); if (const VectorType *VTy = dyn_cast(Ty)) { if (VTy->getNumElements() == 2) { - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isIntegerTy()) Elts.push_back(VectorType::get(Type::getInt64Ty(Context), 2)); else Elts.push_back(VectorType::get(Type::getDoubleTy(Context), 2)); Bytes -= 8; } else { assert(VTy->getNumElements() == 4); - if (VTy->getElementType()->isInteger()) + if (VTy->getElementType()->isIntegerTy()) Elts.push_back(VectorType::get(Type::getInt32Ty(Context), 4)); else Elts.push_back(VectorType::get(Type::getFloatTy(Context), 4)); From criswell at uiuc.edu Mon Feb 15 12:27:47 2010 From: criswell at uiuc.edu (John Criswell) Date: Mon, 15 Feb 2010 18:27:47 -0000 Subject: [llvm-commits] [poolalloc] r96246 - in /poolalloc/trunk: lib/PoolAllocate/PointerCompress.cpp tools/Pa/pa.cpp Message-ID: <201002151827.o1FIRlBu011495@zion.cs.uiuc.edu> Author: criswell Date: Mon Feb 15 12:27:47 2010 New Revision: 96246 URL: http://llvm.org/viewvc/llvm-project?rev=96246&view=rev Log: For now, build everything within the global context. This avoids assertion problems caused by different poolalloc parts putting different values into different contexts. Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp poolalloc/trunk/tools/Pa/pa.cpp Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=96246&r1=96245&r2=96246&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Mon Feb 15 12:27:47 2010 @@ -274,7 +274,7 @@ Elements.push_back(ComputeCompressedType(STy->getElementType(i), NodeOffset+SL->getElementOffset(i), Nodes)); - return StructType::get(STy->getContext(),Elements); + return StructType::get(getGlobalContext(),Elements); } else if (const ArrayType *ATy = dyn_cast(OrigTy)) { return ArrayType::get(ComputeCompressedType(ATy->getElementType(), NodeOffset, Nodes), Modified: poolalloc/trunk/tools/Pa/pa.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/tools/Pa/pa.cpp?rev=96246&r1=96245&r2=96246&view=diff ============================================================================== --- poolalloc/trunk/tools/Pa/pa.cpp (original) +++ poolalloc/trunk/tools/Pa/pa.cpp Mon Feb 15 12:27:47 2010 @@ -70,7 +70,6 @@ std::string mt; std::string & msg = mt; - LLVMContext Context; try { cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n"); sys::PrintStackTraceOnErrorSignal(); @@ -80,7 +79,7 @@ std::string ErrorMessage; if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) { - M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage)); + M.reset(ParseBitcodeFile(Buffer, getGlobalContext(), &ErrorMessage)); delete Buffer; } From nicolas.geoffray at gmail.com Mon Feb 15 12:39:54 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Mon, 15 Feb 2010 19:39:54 +0100 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: <6a8523d61002150947gff763eflfe7bdd4069502c9e@mail.gmail.com> References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> <0E341BE8-60FA-47CB-99B7-3F1301AC1ADA@apple.com> <6a8523d61002150933h385d414du39e45901666824c@mail.gmail.com> <201002151138.37172.dag@cray.com> <6a8523d61002150947gff763eflfe7bdd4069502c9e@mail.gmail.com> Message-ID: On Mon, Feb 15, 2010 at 6:47 PM, Daniel Dunbar wrote > > > You are free to add as many verifier passes as you want, I didn't > suggest removing it, I merely suggested making it a client decision. > Libraries shouldn't impose policy decisions on their clients. > Exactly. I'm not suggesting removing the verifier, but just not run it by default. It should be up to the front-end to decide if it wants the verifier to run. Dan, would you be OK in moving the code to where Daniel suggested? Nicolas > > - Daniel > > > -Dave > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/25af0791/attachment.html From sabre at nondot.org Mon Feb 15 12:55:04 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 18:55:04 -0000 Subject: [llvm-commits] [llvm] r96248 - /llvm/trunk/include/llvm/Support/FormattedStream.h Message-ID: <201002151855.o1FIt4bl012774@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 12:55:04 2010 New Revision: 96248 URL: http://llvm.org/viewvc/llvm-project?rev=96248&view=rev Log: comment fix. Modified: llvm/trunk/include/llvm/Support/FormattedStream.h Modified: llvm/trunk/include/llvm/Support/FormattedStream.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FormattedStream.h?rev=96248&r1=96247&r2=96248&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/FormattedStream.h (original) +++ llvm/trunk/include/llvm/Support/FormattedStream.h Mon Feb 15 12:55:04 2010 @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/FormattedStream.h - Formatted streams ------*- C++ -*-===// +//===-- llvm/Support/FormattedStream.h - Formatted streams ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // From clattner at apple.com Mon Feb 15 13:13:57 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Feb 2010 11:13:57 -0800 Subject: [llvm-commits] [llvm] r96214 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h In-Reply-To: <176E4A09-7C1B-4831-8926-C11DFB56B69A@apple.com> References: <201002150711.o1F7BZiY028560@zion.cs.uiuc.edu> <176E4A09-7C1B-4831-8926-C11DFB56B69A@apple.com> Message-ID: <32D5BA33-7A4F-4151-9400-179C94B5A943@apple.com> On Feb 15, 2010, at 9:21 AM, Dan Gohman wrote: > > On Feb 14, 2010, at 11:11 PM, Chris Lattner wrote: > >> Author: lattner >> Date: Mon Feb 15 01:11:34 2010 >> New Revision: 96214 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=96214&view=rev >> Log: >> give SDValue an operator->, allowing V->isTargetOpcode() and >> many other natural things. > > > I had been gradually moving everything away from using SDValues > as if they were SDNodes. While it's convenient to ignore the > distinction sometimes, it's really hard to follow when it does > matter. I'm ok with it if that is the direction you want to go, but it seems much more natural to treat SDValue as a "rich pointer". It seems much more natural to use V->getOpcode() than V.getOpcode() or V.getOperand() etc. The duplicated methods don't make a lot of sense to me (and yes, I'm to blame for the original poor design). -Chris From clattner at apple.com Mon Feb 15 13:14:40 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Feb 2010 11:14:40 -0800 Subject: [llvm-commits] [dragonegg] r96219 - /dragonegg/trunk/bits_and_bobs.cpp In-Reply-To: <201002151432.o1FEWEMI031644@zion.cs.uiuc.edu> References: <201002151432.o1FEWEMI031644@zion.cs.uiuc.edu> Message-ID: <49EADACA-159F-4CED-B569-E4E0A17F6826@apple.com> On Feb 15, 2010, at 6:32 AM, Duncan Sands wrote: > Author: baldrick > Date: Mon Feb 15 08:32:14 2010 > New Revision: 96219 > > URL: http://llvm.org/viewvc/llvm-project?rev=96219&view=rev > Log: > Do not include a bunch of unused headers. Huh? > > Added: > dragonegg/trunk/bits_and_bobs.cpp > > Added: dragonegg/trunk/bits_and_bobs.cpp > URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/bits_and_bobs.cpp?rev=96219&view=auto > > ============================================================================== > --- dragonegg/trunk/bits_and_bobs.cpp (added) > +++ dragonegg/trunk/bits_and_bobs.cpp Mon Feb 15 08:32:14 2010 > @@ -0,0 +1,11 @@ > +#include > + > +bool flag_odr = false; > + > +int ix86_regparm; > + > +union tree_node; > + > +extern "C" bool contains_aligned_value_p (union tree_node *type) { > + abort(); > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Mon Feb 15 13:17:52 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Feb 2010 11:17:52 -0800 Subject: [llvm-commits] [llvm] r96241 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-02-11-NonTemporal.ll In-Reply-To: <201002151702.o1FH2vXL007197@zion.cs.uiuc.edu> References: <201002151702.o1FH2vXL007197@zion.cs.uiuc.edu> Message-ID: <9684461C-570A-4D1F-8F5C-00B9616D4C8B@apple.com> On Feb 15, 2010, at 9:02 AM, David Greene wrote: > Author: greened > Date: Mon Feb 15 11:02:56 2010 > New Revision: 96241 > > URL: http://llvm.org/viewvc/llvm-project?rev=96241&view=rev > Log: > > Add support for emitting non-temporal stores for DAGs marked > non-temporal. As before, please *dramatically* reduce the testcase. Please be aware of our testcase conventions in the future too. -Chris > > Added: > llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll > Modified: > llvm/trunk/lib/Target/X86/X86InstrSSE.td > > Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=96241&r1=96240&r2=96241&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Feb 15 11:02:56 2010 > @@ -160,6 +160,32 @@ > def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>; > def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>; > > +// MOVNT Support > +// Like 'store', but requires the non-temporal bit to be set > +def nontemporalstore : PatFrag<(ops node:$val, node:$ptr), > + (st node:$val, node:$ptr), [{ > + if (StoreSDNode *ST = dyn_cast(N)) > + return ST->isNonTemporal(); > + return false; > +}]>; > + > +def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), > + (st node:$val, node:$ptr), [{ > + if (StoreSDNode *ST = dyn_cast(N)) > + return ST->isNonTemporal() && !ST->isTruncatingStore() && > + ST->getAddressingMode() == ISD::UNINDEXED && > + ST->getAlignment() >= 16; > + return false; > +}]>; > + > +def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), > + (st node:$val, node:$ptr), [{ > + if (StoreSDNode *ST = dyn_cast(N)) > + return ST->isNonTemporal() && > + ST->getAlignment() < 16; > + return false; > +}]>; > + > def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>; > def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>; > def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>; > @@ -1013,10 +1039,33 @@ > "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>; > > // Non-temporal stores > -def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), > +def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), > "movntps\t{$src, $dst|$dst, $src}", > [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>; > > +let AddedComplexity = 400 in { // Prefer non-temporal versions > +def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), > + "movntps\t{$src, $dst|$dst, $src}", > + [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; > + > +def MOVNTDQ_64mr : PSI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), > + "movntdq\t{$src, $dst|$dst, $src}", > + [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>; > + > +def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst), > + (MOVNTDQ_64mr VR128:$src, addr:$dst)>; > + > +def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), > + "movnti\t{$src, $dst|$dst, $src}", > + [(nontemporalstore (i32 GR32:$src), addr:$dst)]>, > + TB, Requires<[HasSSE2]>; > + > +def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), > + "movnti\t{$src, $dst|$dst, $src}", > + [(nontemporalstore (i64 GR64:$src), addr:$dst)]>, > + TB, Requires<[HasSSE2]>; > +} > + > // Load, store, and memory fence > def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>; > > @@ -2298,17 +2347,30 @@ > [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>; > > // Non-temporal stores > -def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), > - "movntpd\t{$src, $dst|$dst, $src}", > - [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; > -def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), > - "movntdq\t{$src, $dst|$dst, $src}", > - [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; > -def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), > +def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), > + "movntpd\t{$src, $dst|$dst, $src}", > + [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; > +def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), > + "movntdq\t{$src, $dst|$dst, $src}", > + [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; > +def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), > "movnti\t{$src, $dst|$dst, $src}", > [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>, > TB, Requires<[HasSSE2]>; > > +let AddedComplexity = 400 in { // Prefer non-temporal versions > +def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), > + "movntpd\t{$src, $dst|$dst, $src}", > + [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>; > + > +def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), > + "movntdq\t{$src, $dst|$dst, $src}", > + [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; > + > +def : Pat<(alignednontemporalstore (v4i32 VR128:$src), addr:$dst), > + (MOVNTDQmr VR128:$src, addr:$dst)>; > +} > + > // Flush cache > def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src), > "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>, > > Added: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll?rev=96241&view=auto > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll (added) > +++ llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Mon Feb 15 11:02:56 2010 > @@ -0,0 +1,84 @@ > +; RUN: llc < %s -march=x86-64 | FileCheck %s > +; CHECK: movnt > +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" > +target triple = "x86_64-unknown-linux-gnu" > + at blk_ = linkonce global [700000 x i64] zeroinitializer, align 64 ; <[700000 x i64]*> [#uses=3] > + at _dm_my_pe = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] > + at _dm_pes_in_prog = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] > + at _dm_npes_div_mult = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] > + at _dm_npes_div_shift = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] > + at _dm_pe_addr_loc = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] > + at _dm_offset_addr_mask = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] > + > +!0 = metadata !{ i32 1 } > + > +define void @sub_(i32* noalias %n) { > +"file movnt.f90, line 2, bb1": ; srcLine 2 > + %n1 = alloca i32*, align 8 ; [#uses=1] ; [oox.12 : sln.2] > + %i = alloca i32, align 4 ; [#uses=0] ; [oox.14 : sln.2] > + %"$LIS_E0" = alloca i64, align 8 ; [#uses=2] ; [oox.72 : sln.2] > + %"$LCS_0" = alloca i64, align 8 ; [#uses=7] ; [oox.73 : sln.2] > + %"$SI_S1" = alloca i64, align 8 ; [#uses=4] ; [oox.75 : sln.2] > + %"$LCS_S2" = alloca <2 x double>, align 16 ; <<2 x double>*> [#uses=6] ; [oox.76 : sln.2] > + %"$LC_S3" = alloca i64, align 8 ; [#uses=4] ; [oox.77 : sln.2] > + volatile store i32* %n, i32** %n1 ; [oox.12 : sln.2] > + br label %"file movnt.f90, line 2, bb32" ; [oox.0 : sln.0] > + > +"file movnt.f90, line 2, bb32": ; srcLine 2 ; preds = %"file movnt.f90, line 2, bb1" > + store i64 -50000, i64* %"$LC_S3", align 8 ; [oox.160 : sln.10] > + store i64 0, i64* %"$SI_S1", align 8 ; [oox.161 : sln.10] > + store i64 ptrtoint ([700000 x i64]* @blk_ to i64), i64* %"$LIS_E0", align 8 ; [oox.162 : sln.11] > + br label %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25" ; [oox.0 : sln.0] > + > +"file movnt.f90, line 2, in inner vector loop at depth 0, bb25": ; srcLine 2 ; preds = %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23", %"file movnt.f90, line 2, bb32" > + br label %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23" ; [oox.0 : sln.0] > + > +"file movnt.f90, line 11, in inner vector loop at depth 0, bb23": ; srcLine 11 ; preds = %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25" > + %r = load i64* %"$LIS_E0", align 8 ; [#uses=1] ; [oox.159 : sln.11] > + %r2 = load i64* %"$SI_S1", align 8 ; [#uses=1] ; [oox.159 : sln.11] > + %r3 = add i64 %r, %r2 ; [#uses=1] ; [oox.159 : sln.11] > + store i64 %r3, i64* %"$LCS_0", align 8 ; [oox.159 : sln.11] > + %r4 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.160 : sln.11] > + %r5 = add i64 4000000, %r4 ; [#uses=1] ; [oox.160 : sln.11] > + %r6 = inttoptr i64 %r5 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.160 : sln.11] > + %r8 = load <2 x double>* %r6, align 16, !nontemporal !0 ; <<2 x double>> [#uses=1] ; [oox.160 : sln.11] > + store <2 x double> %r8, <2 x double>* %"$LCS_S2", align 8 ; [oox.160 : sln.11] > + %r9 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.161 : sln.11] > + %r10 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.161 : sln.11] > + %r11 = inttoptr i64 %r10 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.161 : sln.11] > + store <2 x double> %r9, <2 x double>* %r11, align 16, !nontemporal !0 ; [oox.161 : sln.11] > + %r13 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.162 : sln.12] > + %r14 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.162 : sln.12] > + %r15 = add i64 800000, %r14 ; [#uses=1] ; [oox.162 : sln.12] > + %r16 = inttoptr i64 %r15 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.162 : sln.12] > + store <2 x double> %r13, <2 x double>* %r16, align 16, !nontemporal !0 ; [oox.162 : sln.12] > + %r18 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.163 : sln.13] > + %r19 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.163 : sln.13] > + %r20 = add i64 1600000, %r19 ; [#uses=1] ; [oox.163 : sln.13] > + %r21 = inttoptr i64 %r20 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.163 : sln.13] > + store <2 x double> %r18, <2 x double>* %r21, align 16, !nontemporal !0 ; [oox.163 : sln.13] > + %r23 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.164 : sln.14] > + %r24 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.164 : sln.14] > + %r25 = add i64 2400000, %r24 ; [#uses=1] ; [oox.164 : sln.14] > + %r26 = inttoptr i64 %r25 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.164 : sln.14] > + store <2 x double> %r23, <2 x double>* %r26, align 16, !nontemporal !0 ; [oox.164 : sln.14] > + %r28 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.165 : sln.15] > + %r29 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.165 : sln.15] > + %r30 = add i64 3200000, %r29 ; [#uses=1] ; [oox.165 : sln.15] > + %r31 = inttoptr i64 %r30 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.165 : sln.15] > + store <2 x double> %r28, <2 x double>* %r31, align 16, !nontemporal !0 ; [oox.165 : sln.15] > + %r33 = load i64* %"$SI_S1", align 8 ; [#uses=1] ; [oox.166 : sln.10] > + %r34 = add i64 16, %r33 ; [#uses=1] ; [oox.166 : sln.10] > + store i64 %r34, i64* %"$SI_S1", align 8 ; [oox.166 : sln.10] > + %r35 = load i64* %"$LC_S3", align 8 ; [#uses=1] ; [oox.167 : sln.10] > + %r36 = add i64 1, %r35 ; [#uses=1] ; [oox.167 : sln.10] > + store i64 %r36, i64* %"$LC_S3", align 8 ; [oox.167 : sln.10] > + %r37 = load i64* %"$LC_S3", align 8 ; [#uses=1] ; [oox.168 : sln.10] > + %r38 = icmp slt i64 %r37, 0 ; [#uses=1] ; [oox.168 : sln.10] > + %r39 = zext i1 %r38 to i64 ; [#uses=1] ; [oox.168 : sln.10] > + %r40 = icmp ne i64 %r39, 0 ; [#uses=1] ; [oox.168 : sln.10] > + br i1 %r40, label %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25", label %"file movnt.f90, line 18, bb5" ; [oox.168 : sln.10] > + > +"file movnt.f90, line 18, bb5": ; srcLine 18 ; preds = %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23" > + ret void ; [oox.159 : sln.18] > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Feb 15 13:41:07 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Feb 2010 19:41:07 -0000 Subject: [llvm-commits] [llvm] r96255 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGISel.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/MSP430/MSP430ISelDAGToDAG.cpp lib/Target/PIC16/PIC16ISelLowering.cpp lib/Target/SystemZ/SystemZISelDAGToDAG.cpp lib/Target/X86/X86ISelDAGToDAG.cpp utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002151941.o1FJf86q015221@zion.cs.uiuc.edu> Author: evancheng Date: Mon Feb 15 13:41:07 2010 New Revision: 96255 URL: http://llvm.org/viewvc/llvm-project?rev=96255&view=rev Log: Split SelectionDAGISel::IsLegalAndProfitableToFold to IsLegalToFold and IsProfitableToFold. The generic version of the later simply checks whether the folding candidate has a single use. This allows the target isel routines more flexibility in deciding whether folding makes sense. The specific case we are interested in is folding constant pool loads with multiple uses. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Mon Feb 15 13:41:07 2010 @@ -85,11 +85,13 @@ return true; } - /// IsLegalAndProfitableToFold - Returns true if the specific operand node N of - /// U can be folded during instruction selection that starts at Root and - /// folding N is profitable. - virtual - bool IsLegalAndProfitableToFold(SDNode *N, SDNode *U, SDNode *Root) const; + /// IsProfitableToFold - Returns true if it's profitable to fold the specific + /// operand node N of U during instruction selection that starts at Root. + virtual bool IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const; + + /// IsLegalToFold - Returns true if the specific operand node N of + /// U can be folded during instruction selection that starts at Root. + virtual bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root) const; /// CreateTargetHazardRecognizer - Return a newly allocated hazard recognizer /// to use for this target when scheduling the DAG. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Feb 15 13:41:07 2010 @@ -1341,8 +1341,7 @@ /// isNonImmUse - Start searching from Root up the DAG to check is Def can /// be reached. Return true if that's the case. However, ignore direct uses /// by ImmedUse (which would be U in the example illustrated in -/// IsLegalAndProfitableToFold) and by Root (which can happen in the store -/// case). +/// IsLegalToFold) and by Root (which can happen in the store case). /// FIXME: to be really generic, we should allow direct use by any node /// that is being folded. But realisticly since we only fold loads which /// have one non-chain use, we only need to watch out for load/op/store @@ -1353,11 +1352,17 @@ return findNonImmUse(Root, Def, ImmedUse, Root, Visited); } -/// IsLegalAndProfitableToFold - Returns true if the specific operand node N of -/// U can be folded during instruction selection that starts at Root and -/// folding N is profitable. -bool SelectionDAGISel::IsLegalAndProfitableToFold(SDNode *N, SDNode *U, - SDNode *Root) const { +/// IsProfitableToFold - Returns true if it's profitable to fold the specific +/// operand node N of U during instruction selection that starts at Root. +bool SelectionDAGISel::IsProfitableToFold(SDValue N, SDNode *U, + SDNode *Root) const { + if (OptLevel == CodeGenOpt::None) return false; + return N.hasOneUse(); +} + +/// IsLegalToFold - Returns true if the specific operand node N of +/// U can be folded during instruction selection that starts at Root. +bool SelectionDAGISel::IsLegalToFold(SDValue N, SDNode *U, SDNode *Root) const { if (OptLevel == CodeGenOpt::None) return false; // If Root use can somehow reach N through a path that that doesn't contain @@ -1411,7 +1416,7 @@ VT = Root->getValueType(Root->getNumValues()-1); } - return !isNonImmUse(Root, N, U); + return !isNonImmUse(Root, N.getNode(), U); } SDNode *SelectionDAGISel::Select_INLINEASM(SDNode *N) { Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Mon Feb 15 13:41:07 2010 @@ -58,6 +58,8 @@ return "ARM Instruction Selection"; } + virtual void InstructionSelect(); + /// getI32Imm - Return a target constant of type i32 with the specified /// value. inline SDValue getI32Imm(unsigned Imm) { @@ -65,7 +67,7 @@ } SDNode *Select(SDNode *N); - virtual void InstructionSelect(); + bool SelectShifterOperandReg(SDNode *Op, SDValue N, SDValue &A, SDValue &B, SDValue &C); bool SelectAddrMode2(SDNode *Op, SDValue N, SDValue &Base, Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Mon Feb 15 13:41:07 2010 @@ -133,8 +133,7 @@ bool MatchWrapper(SDValue N, MSP430ISelAddressMode &AM); bool MatchAddressBase(SDValue N, MSP430ISelAddressMode &AM); - bool IsLegalAndProfitableToFold(SDNode *N, SDNode *U, - SDNode *Root) const; + bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root) const; virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode, @@ -336,8 +335,8 @@ return false; } -bool MSP430DAGToDAGISel::IsLegalAndProfitableToFold(SDNode *N, SDNode *U, - SDNode *Root) const { +bool MSP430DAGToDAGISel::IsLegalToFold(SDValue N, SDNode *U, + SDNode *Root) const { if (OptLevel == CodeGenOpt::None) return false; /// RMW preprocessing creates the following code: @@ -364,11 +363,11 @@ /// during preprocessing) to determine whether it's legal to introduce such /// "cycle" for a moment. DenseMap::const_iterator I = RMWStores.find(Root); - if (I != RMWStores.end() && I->second == N) + if (I != RMWStores.end() && I->second == N.getNode()) return true; // Proceed to 'generic' cycle finder code - return SelectionDAGISel::IsLegalAndProfitableToFold(N, U, Root); + return SelectionDAGISel::IsLegalToFold(N, U, Root); } @@ -656,7 +655,7 @@ unsigned Opc8, unsigned Opc16) { if (N1.getOpcode() == ISD::LOAD && N1.hasOneUse() && - IsLegalAndProfitableToFold(N1.getNode(), Op, Op)) { + IsLegalToFold(N1, Op, Op)) { LoadSDNode *LD = cast(N1); if (!isValidIndexedLoad(LD)) return NULL; Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Mon Feb 15 13:41:07 2010 @@ -1513,8 +1513,7 @@ // Direct load operands are folded in binary operations. But before folding // verify if this folding is legal. Fold only if it is legal otherwise // convert this direct load to a separate memory operation. - if(ISel->IsLegalAndProfitableToFold(Op.getOperand(0).getNode(), - Op.getNode(), Op.getNode())) + if(ISel->IsLegalToFold(Op.getOperand(0), Op.getNode(), Op.getNode())) return false; else MemOp = 0; Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp Mon Feb 15 13:41:07 2010 @@ -594,8 +594,7 @@ bool SystemZDAGToDAGISel::TryFoldLoad(SDNode *P, SDValue N, SDValue &Base, SDValue &Disp, SDValue &Index) { if (ISD::isNON_EXTLoad(N.getNode()) && - N.hasOneUse() && - IsLegalAndProfitableToFold(N.getNode(), P, P)) + IsLegalToFold(N, P, P)) return SelectAddrRRI20(P, N.getOperand(1), Base, Disp, Index); return false; } Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Feb 15 13:41:07 2010 @@ -183,8 +183,9 @@ virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF); - virtual - bool IsLegalAndProfitableToFold(SDNode *N, SDNode *U, SDNode *Root) const; + virtual bool IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const; + + virtual bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root) const; // Include the pieces autogenerated from the target description. #include "X86GenDAGISel.inc" @@ -303,11 +304,18 @@ } -bool X86DAGToDAGISel::IsLegalAndProfitableToFold(SDNode *N, SDNode *U, - SDNode *Root) const { +bool +X86DAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const { if (OptLevel == CodeGenOpt::None) return false; - if (U == Root) + if (!N.hasOneUse()) + return false; + + if (N.getOpcode() != ISD::LOAD) + return true; + + // If N is a load, do additional profitability checks. + if (U == Root) { switch (U->getOpcode()) { default: break; case X86ISD::ADD: @@ -354,9 +362,17 @@ } } } + } + + return true; +} + + +bool X86DAGToDAGISel::IsLegalToFold(SDValue N, SDNode *U, SDNode *Root) const { + if (OptLevel == CodeGenOpt::None) return false; // Proceed to 'generic' cycle finder code - return SelectionDAGISel::IsLegalAndProfitableToFold(N, U, Root); + return SelectionDAGISel::IsLegalToFold(N, U, Root); } /// MoveBelowTokenFactor - Replace TokenFactor operand with load's chain operand @@ -1311,8 +1327,8 @@ InChain = N.getOperand(0).getValue(1); if (ISD::isNON_EXTLoad(InChain.getNode()) && InChain.getValue(0).hasOneUse() && - N.hasOneUse() && - IsLegalAndProfitableToFold(N.getNode(), Pred.getNode(), Op)) { + IsProfitableToFold(N, Pred.getNode(), Op) && + IsLegalToFold(N, Pred.getNode(), Op)) { LoadSDNode *LD = cast(InChain); if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, Disp, Segment)) return false; @@ -1436,8 +1452,8 @@ SDValue &Index, SDValue &Disp, SDValue &Segment) { if (ISD::isNON_EXTLoad(N.getNode()) && - N.hasOneUse() && - IsLegalAndProfitableToFold(N.getNode(), P, P)) + IsProfitableToFold(N, P, P) && + IsLegalToFold(N, P, P)) return SelectAddr(P, N.getOperand(1), Base, Scale, Index, Disp, Segment); return false; } Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96255&r1=96254&r2=96255&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Mon Feb 15 13:41:07 2010 @@ -566,8 +566,11 @@ if (NodeHasChain) OpNo = 1; if (!isRoot) { - // Multiple uses of actual result? - emitCheck(getValueName(RootName) + ".hasOneUse()"); + // Check if it's profitable to fold the node. e.g. Check for multiple uses + // of actual result? + std::string ParentName(RootName.begin(), RootName.end()-1); + emitCheck("IsProfitableToFold(" + getValueName(RootName) + + ", " + getNodeName(ParentName) + ", N)"); EmittedUseCheck = true; if (NodeHasChain) { // If the immediate use can somehow reach this node through another @@ -597,8 +600,7 @@ } if (NeedCheck) { - std::string ParentName(RootName.begin(), RootName.end()-1); - emitCheck("IsLegalAndProfitableToFold(" + getNodeName(RootName) + + emitCheck("IsLegalToFold(" + getValueName(RootName) + ", " + getNodeName(ParentName) + ", N)"); } } From baldrick at free.fr Mon Feb 15 14:08:19 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Feb 2010 21:08:19 +0100 Subject: [llvm-commits] [dragonegg] r96219 - /dragonegg/trunk/bits_and_bobs.cpp In-Reply-To: <49EADACA-159F-4CED-B569-E4E0A17F6826@apple.com> References: <201002151432.o1FEWEMI031644@zion.cs.uiuc.edu> <49EADACA-159F-4CED-B569-E4E0A17F6826@apple.com> Message-ID: <4B79A9B3.80204@free.fr> Hi Chris, >> Do not include a bunch of unused headers. > > Huh? some kind of svn weirdness: it seems to have generated a file deletion followed by an addition of the same file. The change was: a bunch of #includes deleted. Ciao, Duncan. > >> Added: >> dragonegg/trunk/bits_and_bobs.cpp >> >> Added: dragonegg/trunk/bits_and_bobs.cpp >> URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/bits_and_bobs.cpp?rev=96219&view=auto >> >> ============================================================================== >> --- dragonegg/trunk/bits_and_bobs.cpp (added) >> +++ dragonegg/trunk/bits_and_bobs.cpp Mon Feb 15 08:32:14 2010 >> @@ -0,0 +1,11 @@ >> +#include >> + >> +bool flag_odr = false; >> + >> +int ix86_regparm; >> + >> +union tree_node; >> + >> +extern "C" bool contains_aligned_value_p (union tree_node *type) { >> + abort(); >> +} >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From baldrick at free.fr Mon Feb 15 14:40:47 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Feb 2010 20:40:47 -0000 Subject: [llvm-commits] [dragonegg] r96262 - /dragonegg/trunk/Makefile Message-ID: <201002152040.o1FKelkY018392@zion.cs.uiuc.edu> Author: baldrick Date: Mon Feb 15 14:40:46 2010 New Revision: 96262 URL: http://llvm.org/viewvc/llvm-project?rev=96262&view=rev Log: No RTTI or exceptions are required by the plugin itself. Modified: dragonegg/trunk/Makefile Modified: dragonegg/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Makefile?rev=96262&r1=96261&r2=96262&view=diff ============================================================================== --- dragonegg/trunk/Makefile (original) +++ dragonegg/trunk/Makefile Mon Feb 15 14:40:46 2010 @@ -33,10 +33,10 @@ # NOTE: replace with an informative string when doing a release. REVISION:=$(shell svnversion -n .) -CFLAGS+=-Wall -Werror -fPIC -g -O2 +CFLAGS+=-Wall -Werror -fPIC -g -O2 -fno-exceptions CFLAGS+=-DIN_GCC -DREVISION=\"$(REVISION)\" -DTARGET_NAME=\"$(TARGET_TRIPLE)\" CPPFLAGS+=-MD -MP -CXXFLAGS+=$(CFLAGS) $(shell $(LLVM_CONFIG) --cppflags) +CXXFLAGS+=$(CFLAGS) -fno-rtti $(shell $(LLVM_CONFIG) --cppflags) LDFLAGS+=$(shell $(LLVM_CONFIG) --libs analysis core ipo scalaropts target) \ $(shell $(LLVM_CONFIG) --ldflags) From sabre at nondot.org Mon Feb 15 14:47:49 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 20:47:49 -0000 Subject: [llvm-commits] [llvm] r96263 - in /llvm/trunk: lib/Transforms/Utils/Local.cpp test/CodeGen/X86/addr-label-difference.ll test/Transforms/JumpThreading/crash.ll Message-ID: <201002152047.o1FKlovE018758@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 14:47:49 2010 New Revision: 96263 URL: http://llvm.org/viewvc/llvm-project?rev=96263&view=rev Log: fix PR6305 by handling BlockAddress in a helper function called by jump threading. Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp llvm/trunk/test/CodeGen/X86/addr-label-difference.ll llvm/trunk/test/Transforms/JumpThreading/crash.ll Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=96263&r1=96262&r2=96263&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Mon Feb 15 14:47:49 2010 @@ -490,6 +490,17 @@ // Splice all the instructions from PredBB to DestBB. PredBB->getTerminator()->eraseFromParent(); DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList()); + + // Zap anything that took the address of DestBB. Not doing this will give the + // address an invalid value. + if (DestBB->hasAddressTaken()) { + BlockAddress *BA = BlockAddress::get(DestBB); + Constant *Replacement = + ConstantInt::get(llvm::Type::getInt32Ty(BA->getContext()), 1); + BA->replaceAllUsesWith(ConstantExpr::getIntToPtr(Replacement, + BA->getType())); + BA->destroyConstant(); + } // Anything that branched to PredBB now branches to DestBB. PredBB->replaceAllUsesWith(DestBB); Modified: llvm/trunk/test/CodeGen/X86/addr-label-difference.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/addr-label-difference.ll?rev=96263&r1=96262&r2=96263&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/addr-label-difference.ll (original) +++ llvm/trunk/test/CodeGen/X86/addr-label-difference.ll Mon Feb 15 14:47:49 2010 @@ -9,14 +9,18 @@ define void @test(i32 %i) nounwind ssp { entry: + call void @test(i32 1) br label %foo -foo: ; preds = %indirectgoto, %indirectgoto, %indirectgoto, %indirectgoto, %indirectgoto +foo: + call void @test(i32 1) br label %bar -bar: ; preds = %foo, %indirectgoto +bar: + call void @test(i32 1) br label %hack -hack: ; preds = %bar, %indirectgoto +hack: + call void @test(i32 1) ret void } Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=96263&r1=96262&r2=96263&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Mon Feb 15 14:47:49 2010 @@ -313,3 +313,14 @@ for.body: ; preds = %for.cond br label %for.cond } + + +; PR6305 +define void @test11() nounwind { +entry: + br label %A + +A: ; preds = %entry + call void undef(i64 ptrtoint (i8* blockaddress(@test11, %A) to i64)) nounwind + unreachable +} From clattner at apple.com Mon Feb 15 14:48:42 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Feb 2010 12:48:42 -0800 Subject: [llvm-commits] [llvm] r96241 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-02-11-NonTemporal.ll In-Reply-To: <9684461C-570A-4D1F-8F5C-00B9616D4C8B@apple.com> References: <201002151702.o1FH2vXL007197@zion.cs.uiuc.edu> <9684461C-570A-4D1F-8F5C-00B9616D4C8B@apple.com> Message-ID: On Feb 15, 2010, at 11:17 AM, Chris Lattner wrote: > > On Feb 15, 2010, at 9:02 AM, David Greene wrote: > >> Author: greened >> Date: Mon Feb 15 11:02:56 2010 >> New Revision: 96241 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=96241&view=rev >> Log: >> >> Add support for emitting non-temporal stores for DAGs marked >> non-temporal. > > As before, please *dramatically* reduce the testcase. Please be aware of our testcase conventions in the future too. Also, please document the IR extension in langref.html. -Chris From isanbard at gmail.com Mon Feb 15 14:50:54 2010 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Feb 2010 20:50:54 -0000 Subject: [llvm-commits] [llvm] r96264 - /llvm/trunk/include/llvm-c/Core.h Message-ID: <201002152050.o1FKostG018917@zion.cs.uiuc.edu> Author: void Date: Mon Feb 15 14:50:51 2010 New Revision: 96264 URL: http://llvm.org/viewvc/llvm-project?rev=96264&view=rev Log: Renumber Instruction enums in llvm-c. Modified: llvm/trunk/include/llvm-c/Core.h Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=96264&r1=96263&r2=96264&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Mon Feb 15 14:50:51 2010 @@ -123,59 +123,71 @@ } LLVMAttribute; typedef enum { + // Terminator Instructions LLVMRet = 1, LLVMBr = 2, LLVMSwitch = 3, - LLVMInvoke = 4, - LLVMUnwind = 5, - LLVMUnreachable = 6, - LLVMAdd = 7, - LLVMFAdd = 8, - LLVMSub = 9, - LLVMFSub = 10, - LLVMMul = 11, - LLVMFMul = 12, - LLVMUDiv = 13, - LLVMSDiv = 14, - LLVMFDiv = 15, - LLVMURem = 16, - LLVMSRem = 17, - LLVMFRem = 18, - LLVMShl = 19, - LLVMLShr = 20, - LLVMAShr = 21, - LLVMAnd = 22, - LLVMOr = 23, - LLVMXor = 24, - LLVMMalloc = 25, - LLVMFree = 26, - LLVMAlloca = 27, - LLVMLoad = 28, - LLVMStore = 29, - LLVMGetElementPtr = 30, - LLVMTrunk = 31, - LLVMZExt = 32, - LLVMSExt = 33, - LLVMFPToUI = 34, - LLVMFPToSI = 35, - LLVMUIToFP = 36, - LLVMSIToFP = 37, - LLVMFPTrunc = 38, - LLVMFPExt = 39, - LLVMPtrToInt = 40, - LLVMIntToPtr = 41, - LLVMBitCast = 42, - LLVMICmp = 43, - LLVMFCmp = 44, - LLVMPHI = 45, - LLVMCall = 46, - LLVMSelect = 47, - LLVMVAArg = 50, - LLVMExtractElement = 51, - LLVMInsertElement = 52, - LLVMShuffleVector = 53, - LLVMExtractValue = 54, - LLVMInsertValue = 55 + LLVMIndirectBr = 4, + LLVMInvoke = 5, + LLVMUnwind = 6, + LLVMUnreachable = 7, + + // Standard Binary Operators + LLVMAdd = 8, + LLVMFAdd = 9, + LLVMSub = 10, + LLVMFSub = 11, + LLVMMul = 12, + LLVMFMul = 13, + LLVMUDiv = 14, + LLVMSDiv = 15, + LLVMFDiv = 16, + LLVMURem = 17, + LLVMSRem = 18, + LLVMFRem = 19, + + // Logical Operators + LLVMShl = 20, + LLVMLShr = 21, + LLVMAShr = 22, + LLVMAnd = 23, + LLVMOr = 24, + LLVMXor = 25, + + // Memory Operators + LLVMAlloca = 26, + LLVMLoad = 27, + LLVMStore = 28, + LLVMGetElementPtr = 29, + + // Cast Operators + LLVMTrunk = 30, + LLVMZExt = 31, + LLVMSExt = 32, + LLVMFPToUI = 33, + LLVMFPToSI = 34, + LLVMUIToFP = 35, + LLVMSIToFP = 36, + LLVMFPTrunc = 37, + LLVMFPExt = 38, + LLVMPtrToInt = 39, + LLVMIntToPtr = 40, + LLVMBitCast = 41, + + // Other Operators + LLVMICmp = 42, + LLVMFCmp = 43, + LLVMPHI = 44, + LLVMCall = 45, + LLVMSelect = 46, + // UserOp1 + // UserOp2 + LLVMVAArg = 49, + LLVMExtractElement = 50, + LLVMInsertElement = 51, + LLVMShuffleVector = 52, + LLVMExtractValue = 53, + LLVMInsertValue = 54 } LLVMOpcode; typedef enum { From dag at cray.com Mon Feb 15 14:52:37 2010 From: dag at cray.com (David Greene) Date: Mon, 15 Feb 2010 14:52:37 -0600 Subject: [llvm-commits] [llvm] r96241 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-02-11-NonTemporal.ll In-Reply-To: <9684461C-570A-4D1F-8F5C-00B9616D4C8B@apple.com> References: <201002151702.o1FH2vXL007197@zion.cs.uiuc.edu> <9684461C-570A-4D1F-8F5C-00B9616D4C8B@apple.com> Message-ID: <201002151452.37932.dag@cray.com> On Monday 15 February 2010 13:17:52 Chris Lattner wrote: > On Feb 15, 2010, at 9:02 AM, David Greene wrote: > > Author: greened > > Date: Mon Feb 15 11:02:56 2010 > > New Revision: 96241 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=96241&view=rev > > Log: > > > > Add support for emitting non-temporal stores for DAGs marked > > non-temporal. > > As before, please *dramatically* reduce the testcase. Please be aware of > our testcase conventions in the future too. It's already on the way. :) -Dave From sabre at nondot.org Mon Feb 15 14:53:01 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 20:53:01 -0000 Subject: [llvm-commits] [llvm] r96265 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-02-11-NonTemporal.ll Message-ID: <201002152053.o1FKr2BK019039@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 14:53:01 2010 New Revision: 96265 URL: http://llvm.org/viewvc/llvm-project?rev=96265&view=rev Log: revert r96241. It breaks two regression tests, isn't documented, and the testcase needs improvement. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=96265&r1=96264&r2=96265&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Feb 15 14:53:01 2010 @@ -160,32 +160,6 @@ def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>; def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>; -// MOVNT Support -// Like 'store', but requires the non-temporal bit to be set -def nontemporalstore : PatFrag<(ops node:$val, node:$ptr), - (st node:$val, node:$ptr), [{ - if (StoreSDNode *ST = dyn_cast(N)) - return ST->isNonTemporal(); - return false; -}]>; - -def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), - (st node:$val, node:$ptr), [{ - if (StoreSDNode *ST = dyn_cast(N)) - return ST->isNonTemporal() && !ST->isTruncatingStore() && - ST->getAddressingMode() == ISD::UNINDEXED && - ST->getAlignment() >= 16; - return false; -}]>; - -def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), - (st node:$val, node:$ptr), [{ - if (StoreSDNode *ST = dyn_cast(N)) - return ST->isNonTemporal() && - ST->getAlignment() < 16; - return false; -}]>; - def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>; def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>; def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>; @@ -1039,33 +1013,10 @@ "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>; // Non-temporal stores -def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), +def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), "movntps\t{$src, $dst|$dst, $src}", [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>; -let AddedComplexity = 400 in { // Prefer non-temporal versions -def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), - "movntps\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; - -def MOVNTDQ_64mr : PSI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>; - -def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst), - (MOVNTDQ_64mr VR128:$src, addr:$dst)>; - -def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), - "movnti\t{$src, $dst|$dst, $src}", - [(nontemporalstore (i32 GR32:$src), addr:$dst)]>, - TB, Requires<[HasSSE2]>; - -def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), - "movnti\t{$src, $dst|$dst, $src}", - [(nontemporalstore (i64 GR64:$src), addr:$dst)]>, - TB, Requires<[HasSSE2]>; -} - // Load, store, and memory fence def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>; @@ -2347,29 +2298,16 @@ [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>; // Non-temporal stores -def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; -def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; -def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), - "movnti\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>, - TB, Requires<[HasSSE2]>; - -let AddedComplexity = 400 in { // Prefer non-temporal versions -def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), +def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), "movntpd\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>; - + [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), "movntdq\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; - -def : Pat<(alignednontemporalstore (v4i32 VR128:$src), addr:$dst), - (MOVNTDQmr VR128:$src, addr:$dst)>; -} + [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; +def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), + "movnti\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>, + TB, Requires<[HasSSE2]>; // Flush cache def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src), Modified: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll?rev=96265&r1=96264&r2=96265&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Mon Feb 15 14:53:01 2010 @@ -1,84 +0,0 @@ -; RUN: llc < %s -march=x86-64 | FileCheck %s -; CHECK: movnt -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" -target triple = "x86_64-unknown-linux-gnu" - at blk_ = linkonce global [700000 x i64] zeroinitializer, align 64 ; <[700000 x i64]*> [#uses=3] - at _dm_my_pe = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] - at _dm_pes_in_prog = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] - at _dm_npes_div_mult = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] - at _dm_npes_div_shift = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] - at _dm_pe_addr_loc = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] - at _dm_offset_addr_mask = external global [1 x i64], align 64 ; <[1 x i64]*> [#uses=1] - -!0 = metadata !{ i32 1 } - -define void @sub_(i32* noalias %n) { -"file movnt.f90, line 2, bb1": ; srcLine 2 - %n1 = alloca i32*, align 8 ; [#uses=1] ; [oox.12 : sln.2] - %i = alloca i32, align 4 ; [#uses=0] ; [oox.14 : sln.2] - %"$LIS_E0" = alloca i64, align 8 ; [#uses=2] ; [oox.72 : sln.2] - %"$LCS_0" = alloca i64, align 8 ; [#uses=7] ; [oox.73 : sln.2] - %"$SI_S1" = alloca i64, align 8 ; [#uses=4] ; [oox.75 : sln.2] - %"$LCS_S2" = alloca <2 x double>, align 16 ; <<2 x double>*> [#uses=6] ; [oox.76 : sln.2] - %"$LC_S3" = alloca i64, align 8 ; [#uses=4] ; [oox.77 : sln.2] - volatile store i32* %n, i32** %n1 ; [oox.12 : sln.2] - br label %"file movnt.f90, line 2, bb32" ; [oox.0 : sln.0] - -"file movnt.f90, line 2, bb32": ; srcLine 2 ; preds = %"file movnt.f90, line 2, bb1" - store i64 -50000, i64* %"$LC_S3", align 8 ; [oox.160 : sln.10] - store i64 0, i64* %"$SI_S1", align 8 ; [oox.161 : sln.10] - store i64 ptrtoint ([700000 x i64]* @blk_ to i64), i64* %"$LIS_E0", align 8 ; [oox.162 : sln.11] - br label %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25" ; [oox.0 : sln.0] - -"file movnt.f90, line 2, in inner vector loop at depth 0, bb25": ; srcLine 2 ; preds = %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23", %"file movnt.f90, line 2, bb32" - br label %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23" ; [oox.0 : sln.0] - -"file movnt.f90, line 11, in inner vector loop at depth 0, bb23": ; srcLine 11 ; preds = %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25" - %r = load i64* %"$LIS_E0", align 8 ; [#uses=1] ; [oox.159 : sln.11] - %r2 = load i64* %"$SI_S1", align 8 ; [#uses=1] ; [oox.159 : sln.11] - %r3 = add i64 %r, %r2 ; [#uses=1] ; [oox.159 : sln.11] - store i64 %r3, i64* %"$LCS_0", align 8 ; [oox.159 : sln.11] - %r4 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.160 : sln.11] - %r5 = add i64 4000000, %r4 ; [#uses=1] ; [oox.160 : sln.11] - %r6 = inttoptr i64 %r5 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.160 : sln.11] - %r8 = load <2 x double>* %r6, align 16, !nontemporal !0 ; <<2 x double>> [#uses=1] ; [oox.160 : sln.11] - store <2 x double> %r8, <2 x double>* %"$LCS_S2", align 8 ; [oox.160 : sln.11] - %r9 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.161 : sln.11] - %r10 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.161 : sln.11] - %r11 = inttoptr i64 %r10 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.161 : sln.11] - store <2 x double> %r9, <2 x double>* %r11, align 16, !nontemporal !0 ; [oox.161 : sln.11] - %r13 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.162 : sln.12] - %r14 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.162 : sln.12] - %r15 = add i64 800000, %r14 ; [#uses=1] ; [oox.162 : sln.12] - %r16 = inttoptr i64 %r15 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.162 : sln.12] - store <2 x double> %r13, <2 x double>* %r16, align 16, !nontemporal !0 ; [oox.162 : sln.12] - %r18 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.163 : sln.13] - %r19 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.163 : sln.13] - %r20 = add i64 1600000, %r19 ; [#uses=1] ; [oox.163 : sln.13] - %r21 = inttoptr i64 %r20 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.163 : sln.13] - store <2 x double> %r18, <2 x double>* %r21, align 16, !nontemporal !0 ; [oox.163 : sln.13] - %r23 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.164 : sln.14] - %r24 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.164 : sln.14] - %r25 = add i64 2400000, %r24 ; [#uses=1] ; [oox.164 : sln.14] - %r26 = inttoptr i64 %r25 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.164 : sln.14] - store <2 x double> %r23, <2 x double>* %r26, align 16, !nontemporal !0 ; [oox.164 : sln.14] - %r28 = load <2 x double>* %"$LCS_S2", align 8 ; <<2 x double>> [#uses=1] ; [oox.165 : sln.15] - %r29 = load i64* %"$LCS_0", align 8 ; [#uses=1] ; [oox.165 : sln.15] - %r30 = add i64 3200000, %r29 ; [#uses=1] ; [oox.165 : sln.15] - %r31 = inttoptr i64 %r30 to <2 x double>* ; <<2 x double>*> [#uses=2] ; [oox.165 : sln.15] - store <2 x double> %r28, <2 x double>* %r31, align 16, !nontemporal !0 ; [oox.165 : sln.15] - %r33 = load i64* %"$SI_S1", align 8 ; [#uses=1] ; [oox.166 : sln.10] - %r34 = add i64 16, %r33 ; [#uses=1] ; [oox.166 : sln.10] - store i64 %r34, i64* %"$SI_S1", align 8 ; [oox.166 : sln.10] - %r35 = load i64* %"$LC_S3", align 8 ; [#uses=1] ; [oox.167 : sln.10] - %r36 = add i64 1, %r35 ; [#uses=1] ; [oox.167 : sln.10] - store i64 %r36, i64* %"$LC_S3", align 8 ; [oox.167 : sln.10] - %r37 = load i64* %"$LC_S3", align 8 ; [#uses=1] ; [oox.168 : sln.10] - %r38 = icmp slt i64 %r37, 0 ; [#uses=1] ; [oox.168 : sln.10] - %r39 = zext i1 %r38 to i64 ; [#uses=1] ; [oox.168 : sln.10] - %r40 = icmp ne i64 %r39, 0 ; [#uses=1] ; [oox.168 : sln.10] - br i1 %r40, label %"file movnt.f90, line 2, in inner vector loop at depth 0, bb25", label %"file movnt.f90, line 18, bb5" ; [oox.168 : sln.10] - -"file movnt.f90, line 18, bb5": ; srcLine 18 ; preds = %"file movnt.f90, line 11, in inner vector loop at depth 0, bb23" - ret void ; [oox.159 : sln.18] -} From isanbard at gmail.com Mon Feb 15 14:53:17 2010 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Feb 2010 20:53:17 -0000 Subject: [llvm-commits] [llvm] r96266 - /llvm/trunk/include/llvm-c/Core.h Message-ID: <201002152053.o1FKrHjh019069@zion.cs.uiuc.edu> Author: void Date: Mon Feb 15 14:53:17 2010 New Revision: 96266 URL: http://llvm.org/viewvc/llvm-project?rev=96266&view=rev Log: Remove c++ style comments from c header. Modified: llvm/trunk/include/llvm-c/Core.h Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=96266&r1=96265&r2=96266&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Mon Feb 15 14:53:17 2010 @@ -123,7 +123,7 @@ } LLVMAttribute; typedef enum { - // Terminator Instructions + /* Terminator Instructions */ LLVMRet = 1, LLVMBr = 2, LLVMSwitch = 3, @@ -132,7 +132,7 @@ LLVMUnwind = 6, LLVMUnreachable = 7, - // Standard Binary Operators + /* Standard Binary Operators */ LLVMAdd = 8, LLVMFAdd = 9, LLVMSub = 10, @@ -146,7 +146,7 @@ LLVMSRem = 18, LLVMFRem = 19, - // Logical Operators + /* Logical Operators */ LLVMShl = 20, LLVMLShr = 21, LLVMAShr = 22, @@ -154,13 +154,13 @@ LLVMOr = 24, LLVMXor = 25, - // Memory Operators + /* Memory Operators */ LLVMAlloca = 26, LLVMLoad = 27, LLVMStore = 28, LLVMGetElementPtr = 29, - // Cast Operators + /* Cast Operators */ LLVMTrunk = 30, LLVMZExt = 31, LLVMSExt = 32, @@ -174,14 +174,14 @@ LLVMIntToPtr = 40, LLVMBitCast = 41, - // Other Operators + /* Other Operators */ LLVMICmp = 42, LLVMFCmp = 43, LLVMPHI = 44, LLVMCall = 45, LLVMSelect = 46, - // UserOp1 - // UserOp2 + /* UserOp1 */ + /* UserOp2 */ LLVMVAArg = 49, LLVMExtractElement = 50, LLVMInsertElement = 51, From espindola at google.com Mon Feb 15 15:00:34 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 15 Feb 2010 16:00:34 -0500 Subject: [llvm-commits] [llvm-gcc][patch] Merge SVR4ABI and DefaultABI Message-ID: <38a0d8451002151300t6c1ee2aw11efa8992b62c21a@mail.gmail.com> The attached patch merges the two implementations of the ABI. It moves the ppc specific code to the config/rs6000 directory and adds the macro LLVM_TRY_PASS_AGGREGATE_CUSTOM to access it. It is a nop for non linux ppc since that macro is defined to false by default. I tested that llvm-gcc bootstraps on x86_64 linux and that a llvm-gcc targeting ppc linux uses llvm_rs6000_try_pass_aggregate_custom. Is it OK? 8 files changed, 134 insertions(+), 497 deletions(-) Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: merge.patch Type: text/x-diff Size: 26970 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/5e6a7c61/attachment.bin From daniel at zuster.org Mon Feb 15 15:08:22 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 15 Feb 2010 21:08:22 -0000 Subject: [llvm-commits] [llvm] r96269 - /llvm/trunk/lib/Bitcode/Reader/BitReader.cpp Message-ID: <201002152108.o1FL8Mmo019810@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Feb 15 15:08:22 2010 New Revision: 96269 URL: http://llvm.org/viewvc/llvm-project?rev=96269&view=rev Log: Simplify. Modified: llvm/trunk/lib/Bitcode/Reader/BitReader.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitReader.cpp?rev=96269&r1=96268&r2=96269&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitReader.cpp Mon Feb 15 15:08:22 2010 @@ -21,17 +21,8 @@ Optionally returns a human-readable error message via OutMessage. */ LLVMBool LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutModule, char **OutMessage) { - std::string Message; - - *OutModule = wrap(ParseBitcodeFile(unwrap(MemBuf), getGlobalContext(), - &Message)); - if (!*OutModule) { - if (OutMessage) - *OutMessage = strdup(Message.c_str()); - return 1; - } - - return 0; + return LLVMParseBitcodeInContext(wrap(&getGlobalContext()), MemBuf, OutModule, + OutMessage); } LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef, @@ -57,18 +48,8 @@ LLVMBool LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf, LLVMModuleProviderRef *OutMP, char **OutMessage) { - std::string Message; - - *OutMP = reinterpret_cast( - getLazyBitcodeModule(unwrap(MemBuf), getGlobalContext(), &Message)); - - if (!*OutMP) { - if (OutMessage) - *OutMessage = strdup(Message.c_str()); - return 1; - } - - return 0; + return LLVMGetBitcodeModuleProviderInContext(wrap(&getGlobalContext()), + MemBuf, OutMP, OutMessage); } LLVMBool LLVMGetBitcodeModuleProviderInContext(LLVMContextRef ContextRef, From dalej at apple.com Mon Feb 15 15:12:20 2010 From: dalej at apple.com (Dale Johannesen) Date: Mon, 15 Feb 2010 13:12:20 -0800 Subject: [llvm-commits] [llvm-gcc][patch] Merge SVR4ABI and DefaultABI In-Reply-To: <38a0d8451002151300t6c1ee2aw11efa8992b62c21a@mail.gmail.com> References: <38a0d8451002151300t6c1ee2aw11efa8992b62c21a@mail.gmail.com> Message-ID: On Feb 15, 2010, at 1:00 PMPST, Rafael Espindola wrote: > The attached patch merges the two implementations of the ABI. It moves > the ppc specific code to the config/rs6000 directory and adds the > macro LLVM_TRY_PASS_AGGREGATE_CUSTOM to access it. It is a nop for non > linux ppc since that macro is defined to false by default. > > I tested that llvm-gcc bootstraps on x86_64 linux and that a llvm-gcc > targeting ppc linux uses llvm_rs6000_try_pass_aggregate_custom. > > Is it OK? It won't change anything on non-ppc, for sure. I'm not so sure about Darwin ppc. I'd expect we need +#define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \ + false in rs6000/darwin.h. Does that look right? I'll give it a try. > 8 files changed, 134 insertions(+), 497 deletions(-) > > Cheers, > -- > Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: merge.patch Type: text/x-diff Size: 26971 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/1532a919/attachment.bin -------------- next part -------------- > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Mon Feb 15 15:14:50 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Feb 2010 21:14:50 -0000 Subject: [llvm-commits] [llvm] r96271 - /llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Message-ID: <201002152114.o1FLEojg020170@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 15:14:50 2010 New Revision: 96271 URL: http://llvm.org/viewvc/llvm-project?rev=96271&view=rev Log: remove empty file. Removed: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Removed: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll?rev=96270&view=auto ============================================================================== (empty) From espindola at google.com Mon Feb 15 15:17:37 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 15 Feb 2010 16:17:37 -0500 Subject: [llvm-commits] [llvm-gcc][patch] Merge SVR4ABI and DefaultABI In-Reply-To: References: <38a0d8451002151300t6c1ee2aw11efa8992b62c21a@mail.gmail.com> Message-ID: <38a0d8451002151317g39d4035ue1c07f84120201b@mail.gmail.com> > It won't change anything ?on non-ppc, for sure. ?I'm not so sure about > Darwin ppc. ?I'd expect we need > > +#define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) ? ?\ > + ?false > > in rs6000/darwin.h. ?Does that look right? ?I'll give it a try. I don't think it is necessary as llvm_rs6000_try_pass_aggregate_custom starts with if (!isSVR4ABI()) return false; and isSVR4ABI is defined as static bool isSVR4ABI() { #if defined(POWERPC_LINUX) && (TARGET_64BIT == 0) return true; #else return false; #endif } Cheers, -- Rafael ?vila de Esp?ndola From nicholas at mxc.ca Mon Feb 15 15:27:20 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 15 Feb 2010 21:27:20 -0000 Subject: [llvm-commits] [llvm] r96272 - /llvm/trunk/lib/VMCore/Globals.cpp Message-ID: <201002152127.o1FLRKsv020683@zion.cs.uiuc.edu> Author: nicholas Date: Mon Feb 15 15:27:20 2010 New Revision: 96272 URL: http://llvm.org/viewvc/llvm-project?rev=96272&view=rev Log: A function with no Module owner isn't materializable. This fixes F->dump() for functions not embedded within modules. Modified: llvm/trunk/lib/VMCore/Globals.cpp Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=96272&r1=96271&r2=96272&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Mon Feb 15 15:27:20 2010 @@ -44,10 +44,10 @@ } bool GlobalValue::isMaterializable() const { - return getParent()->isMaterializable(this); + return getParent() && getParent()->isMaterializable(this); } bool GlobalValue::isDematerializable() const { - return getParent()->isDematerializable(this); + return getParent() && getParent()->isDematerializable(this); } bool GlobalValue::Materialize(std::string *ErrInfo) { return getParent()->Materialize(this, ErrInfo); From nicholas at mxc.ca Mon Feb 15 15:27:57 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 15 Feb 2010 21:27:57 -0000 Subject: [llvm-commits] [llvm] r96273 - /llvm/trunk/lib/VMCore/PassManager.cpp Message-ID: <201002152127.o1FLRvVF020713@zion.cs.uiuc.edu> Author: nicholas Date: Mon Feb 15 15:27:56 2010 New Revision: 96273 URL: http://llvm.org/viewvc/llvm-project?rev=96273&view=rev Log: Don't try to materialize a function that isn't materializable anyways. This fixes a crash using FPM on a Function that isn't owned by a Module. Modified: llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=96273&r1=96272&r2=96273&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Mon Feb 15 15:27:56 2010 @@ -1220,9 +1220,11 @@ /// so, return true. /// bool FunctionPassManager::run(Function &F) { - std::string errstr; - if (F.Materialize(&errstr)) { - llvm_report_error("Error reading bitcode file: " + errstr); + if (F.isMaterializable()) { + std::string errstr; + if (F.Materialize(&errstr)) { + llvm_report_error("Error reading bitcode file: " + errstr); + } } return FPM->run(F); } From nicholas at mxc.ca Mon Feb 15 15:52:05 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 15 Feb 2010 21:52:05 -0000 Subject: [llvm-commits] [llvm] r96275 - /llvm/trunk/lib/VMCore/Verifier.cpp Message-ID: <201002152152.o1FLq5kd022046@zion.cs.uiuc.edu> Author: nicholas Date: Mon Feb 15 15:52:04 2010 New Revision: 96275 URL: http://llvm.org/viewvc/llvm-project?rev=96275&view=rev Log: Fix crash in VerifyType when checking Contexts. Because there may not be a Module (we were called with verifyFunction and an unowned Function) we can't rely on Mod->getContext(). Modified: llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96275&r1=96274&r2=96275&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Feb 15 15:52:04 2010 @@ -161,7 +161,8 @@ VerifierFailureAction action; // What to do if verification fails. Module *Mod; // Module we are verifying right now - DominatorTree *DT; // Dominator Tree, caution can be null! + LLVMContext *Context; // Context within which we are verifying + DominatorTree *DT; // Dominator Tree, caution can be null! std::string Messages; raw_string_ostream MessagesStr; @@ -178,24 +179,25 @@ Verifier() : FunctionPass(&ID), Broken(false), RealPass(true), action(AbortProcessAction), - DT(0), MessagesStr(Messages) {} + Mod(0), Context(0), DT(0), MessagesStr(Messages) {} explicit Verifier(VerifierFailureAction ctn) : FunctionPass(&ID), - Broken(false), RealPass(true), action(ctn), DT(0), + Broken(false), RealPass(true), action(ctn), Mod(0), Context(0), DT(0), MessagesStr(Messages) {} explicit Verifier(bool AB) : FunctionPass(&ID), Broken(false), RealPass(true), - action( AB ? AbortProcessAction : PrintMessageAction), DT(0), - MessagesStr(Messages) {} + action( AB ? AbortProcessAction : PrintMessageAction), Mod(0), + Context(0), DT(0), MessagesStr(Messages) {} explicit Verifier(DominatorTree &dt) : FunctionPass(&ID), - Broken(false), RealPass(false), action(PrintMessageAction), - DT(&dt), MessagesStr(Messages) {} + Broken(false), RealPass(false), action(PrintMessageAction), Mod(0), + Context(0), DT(&dt), MessagesStr(Messages) {} bool doInitialization(Module &M) { Mod = &M; + Context = &M.getContext(); verifyTypeSymbolTable(M.getTypeSymbolTable()); // If this is a real pass, in a pass manager, we must abort before @@ -211,6 +213,7 @@ if (RealPass) DT = &getAnalysis(); Mod = F.getParent(); + if (!Context) Context = &F.getContext(); visit(F); InstsInThisBlock.clear(); @@ -596,6 +599,9 @@ const FunctionType *FT = F.getFunctionType(); unsigned NumArgs = F.arg_size(); + Assert1(Context == &F.getContext(), + "Function context does not match Module context!", &F); + Assert1(!F.hasCommonLinkage(), "Functions may not have common linkage", &F); Assert2(FT->getNumParams() == NumArgs, "# formal arguments must match # of arguments for function type!", @@ -1482,7 +1488,7 @@ void Verifier::VerifyType(const Type *Ty) { if (!Types.insert(Ty)) return; - Assert1(&Mod->getContext() == &Ty->getContext(), + Assert1(Context == &Ty->getContext(), "Type context does not match Module context!", Ty); switch (Ty->getTypeID()) { From bob.wilson at apple.com Mon Feb 15 15:56:40 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 15 Feb 2010 21:56:40 -0000 Subject: [llvm-commits] [llvm] r96277 - /llvm/trunk/test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll Message-ID: <201002152156.o1FLueAc022242@zion.cs.uiuc.edu> Author: bwilson Date: Mon Feb 15 15:56:40 2010 New Revision: 96277 URL: http://llvm.org/viewvc/llvm-project?rev=96277&view=rev Log: Last week we were generating code with duplicate induction variables in this test, but the problem seems to have gone away today. Add a check to make sure it doesn't come back. Modified: llvm/trunk/test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll Modified: llvm/trunk/test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll?rev=96277&r1=96276&r2=96277&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2010-02-11-phi-cycle.ll Mon Feb 15 15:56:40 2010 @@ -58,6 +58,10 @@ br label %bb2 bb2: ; preds = %bb1, %bb +; also check for duplicate induction variables (radar 7645034) +; CHECK: subs r{{.*}}, #1 +; CHECK-NOT: subs r{{.*}}, #1 +; CHECK: pop %u.0 = phi i64 [ %ins, %bb1 ], [ %u.17, %bb ] ; [#uses=2] %indvar.next = add i32 %indvar, 1 ; [#uses=2] %exitcond = icmp eq i32 %indvar.next, %tmp ; [#uses=1] From stoklund at 2pi.dk Mon Feb 15 16:03:30 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 15 Feb 2010 22:03:30 -0000 Subject: [llvm-commits] [llvm] r96279 - in /llvm/trunk: lib/CodeGen/ProcessImplicitDefs.cpp test/CodeGen/X86/2010-02-15-ImplicitDefBug.ll Message-ID: <201002152203.o1FM3UOX022555@zion.cs.uiuc.edu> Author: stoklund Date: Mon Feb 15 16:03:29 2010 New Revision: 96279 URL: http://llvm.org/viewvc/llvm-project?rev=96279&view=rev Log: Fix PR6300. A virtual register can be used before it is defined in the same MBB if the MBB is part of a loop. Teach the implicit-def pass about this case. Added: llvm/trunk/test/CodeGen/X86/2010-02-15-ImplicitDefBug.ll Modified: llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp Modified: llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp?rev=96279&r1=96278&r2=96279&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp (original) +++ llvm/trunk/lib/CodeGen/ProcessImplicitDefs.cpp Mon Feb 15 16:03:29 2010 @@ -205,10 +205,9 @@ // Process each use instruction once. for (MachineRegisterInfo::use_iterator UI = mri_->use_begin(Reg), UE = mri_->use_end(); UI != UE; ++UI) { - MachineInstr *RMI = &*UI; - MachineBasicBlock *RMBB = RMI->getParent(); - if (RMBB == MBB) + if (UI.getOperand().isUndef()) continue; + MachineInstr *RMI = &*UI; if (ModInsts.insert(RMI)) RUses.push_back(RMI); } Added: llvm/trunk/test/CodeGen/X86/2010-02-15-ImplicitDefBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-02-15-ImplicitDefBug.ll?rev=96279&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-02-15-ImplicitDefBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-02-15-ImplicitDefBug.ll Mon Feb 15 16:03:29 2010 @@ -0,0 +1,80 @@ +; RUN: llc < %s > %t +; PR6300 +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" +target triple = "i386-pc-linux-gnu" + +; When the "154" loops back onto itself, it defines a register after using it. +; The first value of the register is implicit-def. + +%"struct location_chain_def" = type { %"struct location_chain_def"*, %"struct rtx_def"*, %"struct rtx_def"*, i32 } +%"struct real_value" = type { i32, [5 x i32] } +%"struct rtx_def" = type { i16, i8, i8, %"union u" } +%"union u" = type { %"struct real_value" } + +define i32 @variable_union(i8** nocapture %slot, i8* nocapture %data) nounwind { +entry: + br i1 undef, label %"4.thread", label %"3" + +"4.thread": ; preds = %entry + unreachable + +"3": ; preds = %entry + br i1 undef, label %"19", label %"20" + +"19": ; preds = %"3" + unreachable + +"20": ; preds = %"3" + br i1 undef, label %"56.preheader", label %dv_onepart_p.exit + +dv_onepart_p.exit: ; preds = %"20" + unreachable + +"56.preheader": ; preds = %"20" + br label %"56" + +"50": ; preds = %"57" + br label %"56" + +"56": ; preds = %"50", %"56.preheader" + br i1 undef, label %"57", label %"58" + +"57": ; preds = %"56" + br i1 undef, label %"50", label %"58" + +"58": ; preds = %"57", %"56" + br i1 undef, label %"62", label %"63" + +"62": ; preds = %"58" + unreachable + +"63": ; preds = %"58" + br i1 undef, label %"67", label %"66" + +"66": ; preds = %"63" + br label %"67" + +"67": ; preds = %"66", %"63" + br label %"68" + +"68": ; preds = %"161", %"67" + br i1 undef, label %"153", label %"161" + +"153": ; preds = %"68" + br i1 undef, label %"160", label %bb.nph46 + +bb.nph46: ; preds = %"153" + br label %"154" + +"154": ; preds = %"154", %bb.nph46 + %0 = phi %"struct location_chain_def"** [ undef, %bb.nph46 ], [ %1, %"154" ] ; <%"struct location_chain_def"**> [#uses=1] + %1 = bitcast i8* undef to %"struct location_chain_def"** ; <%"struct location_chain_def"**> [#uses=1] + store %"struct location_chain_def"* undef, %"struct location_chain_def"** %0, align 4 + br i1 undef, label %"160", label %"154" + +"160": ; preds = %"154", %"153" + br label %"161" + +"161": ; preds = %"160", %"68" + br label %"68" +} From nicholas at mxc.ca Mon Feb 15 16:09:09 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 15 Feb 2010 22:09:09 -0000 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp Message-ID: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> Author: nicholas Date: Mon Feb 15 16:09:09 2010 New Revision: 96282 URL: http://llvm.org/viewvc/llvm-project?rev=96282&view=rev Log: Teach the verifier to check the condition on a branch and ensure that it has 'i1' type. Added: llvm/trunk/unittests/VMCore/VerifierTest.cpp Modified: llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96282&r1=96281&r2=96282&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Feb 15 16:09:09 2010 @@ -317,6 +317,7 @@ void visitStoreInst(StoreInst &SI); void visitInstruction(Instruction &I); void visitTerminatorInst(TerminatorInst &I); + void visitBranchInst(BranchInst &BI); void visitReturnInst(ReturnInst &RI); void visitSwitchInst(SwitchInst &SI); void visitSelectInst(SelectInst &SI); @@ -749,6 +750,14 @@ visitInstruction(I); } +void Verifier::visitBranchInst(BranchInst &BI) { + if (BI.isConditional()) { + Assert2(BI.getCondition()->getType()->isIntegerTy(1), + "Branch condition is not 'i1' type!", &BI, BI.getCondition()); + } + visitTerminatorInst(BI); +} + void Verifier::visitReturnInst(ReturnInst &RI) { Function *F = RI.getParent()->getParent(); unsigned N = RI.getNumOperands(); Added: llvm/trunk/unittests/VMCore/VerifierTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/VerifierTest.cpp?rev=96282&view=auto ============================================================================== --- llvm/trunk/unittests/VMCore/VerifierTest.cpp (added) +++ llvm/trunk/unittests/VMCore/VerifierTest.cpp Mon Feb 15 16:09:09 2010 @@ -0,0 +1,44 @@ +//===- llvm/unittest/VMCore/VerifierTest.cpp - Verifier unit tests --------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Function.h" +#include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" +#include "llvm/Analysis/Verifier.h" +#include "gtest/gtest.h" + +namespace llvm { +namespace { + +TEST(VerifierTest, Branch_i1) { + LLVMContext &C = getGlobalContext(); + FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); + Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage); + BasicBlock *Entry = BasicBlock::Create(C, "entry", F); + BasicBlock *Exit = BasicBlock::Create(C, "exit", F); + ReturnInst::Create(C, Exit); + + // To avoid triggering an assertion in BranchInst::Create, we first create + // a branch with an 'i1' condition ... + + Constant *False = ConstantInt::getFalse(C); + BranchInst *BI = BranchInst::Create(Exit, Exit, False, Entry); + + // ... then use setOperand to redirect it to a value of different type. + + Constant *Zero32 = ConstantInt::get(IntegerType::get(C, 32), 0); + BI->setOperand(0, Zero32); + + EXPECT_TRUE(verifyFunction(*F, ReturnStatusAction)); +} + +} +} From asl at math.spbu.ru Mon Feb 15 16:36:00 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Feb 2010 22:36:00 -0000 Subject: [llvm-commits] [llvm] r96285 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/Target/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ test/CodeGen/Generic/ Message-ID: <201002152236.o1FMa13w024315@zion.cs.uiuc.edu> Author: asl Date: Mon Feb 15 16:35:59 2010 New Revision: 96285 URL: http://llvm.org/viewvc/llvm-project?rev=96285&view=rev Log: Preliminary patch to improve dwarf EH generation - Hooks to return Personality / FDE / LSDA / TType encoding depending on target / options (e.g. code model / relocation model) - MCIzation of Dwarf EH printer to use encoding information - Stub generation for ELF target (needed for indirect references) - Some other small changes here and there Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h llvm/trunk/include/llvm/Support/Dwarf.h llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/include/llvm/Target/TargetMachine.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.h llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h llvm/trunk/test/CodeGen/Generic/2007-05-05-Personality.ll Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Mon Feb 15 16:35:59 2010 @@ -50,6 +50,7 @@ //===----------------------------------------------------------------------===// // Forward declarations. class Constant; +class MCSymbol; class MDNode; class GlobalVariable; class MachineBasicBlock; @@ -66,6 +67,12 @@ class MachineModuleInfoImpl { public: virtual ~MachineModuleInfoImpl(); + + typedef std::vector > + SymbolListTy; +protected: + static SymbolListTy + GetSortedStubs(const DenseMap &Map); }; Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfoImpls.h Mon Feb 15 16:35:59 2010 @@ -19,7 +19,7 @@ namespace llvm { class MCSymbol; - + /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation /// for MachO targets. class MachineModuleInfoMachO : public MachineModuleInfoImpl { @@ -54,10 +54,8 @@ assert(Sym && "Key cannot be null"); return HiddenGVStubs[Sym]; } - + /// Accessor methods to return the set of stubs in sorted order. - typedef std::vector > SymbolListTy; - SymbolListTy GetFnStubList() const { return GetSortedStubs(FnStubs); } @@ -67,12 +65,31 @@ SymbolListTy GetHiddenGVStubList() const { return GetSortedStubs(HiddenGVStubs); } - - private: - static SymbolListTy - GetSortedStubs(const DenseMap &Map); }; - + + /// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation + /// for ELF targets. + class MachineModuleInfoELF : public MachineModuleInfoImpl { + /// GVStubs - These stubs are used to materialize global addresses in PIC + /// mode. + DenseMap GVStubs; + + virtual void Anchor(); // Out of line virtual method. + public: + MachineModuleInfoELF(const MachineModuleInfo &) {} + + MCSymbol *&getGVStubEntry(MCSymbol *Sym) { + assert(Sym && "Key cannot be null"); + return GVStubs[Sym]; + } + + /// Accessor methods to return the set of stubs in sorted order. + + SymbolListTy GetGVStubList() const { + return GetSortedStubs(GVStubs); + } + }; + } // end namespace llvm #endif Modified: llvm/trunk/include/llvm/Support/Dwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Dwarf.h (original) +++ llvm/trunk/include/llvm/Support/Dwarf.h Mon Feb 15 16:35:59 2010 @@ -580,7 +580,6 @@ /// CallFrameString - Return the string for the specified call frame instruction /// encodings. const char *CallFrameString(unsigned Encoding); - } // End of namespace dwarf } // End of namespace llvm Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Mon Feb 15 16:35:59 2010 @@ -25,6 +25,7 @@ class MCExpr; class MCSection; class MCSectionMachO; + class MCSymbol; class MCContext; class GlobalValue; class TargetMachine; @@ -175,23 +176,22 @@ return 0; } - /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a - /// pc-relative reference to the specified global variable from exception - /// handling information. In addition to the symbol, this returns - /// by-reference: - /// - /// IsIndirect - True if the returned symbol is actually a stub that contains - /// the address of the symbol, false if the symbol is the global itself. - /// - /// IsPCRel - True if the symbol reference is already pc-relative, false if - /// the caller needs to subtract off the address of the reference from the - /// symbol. + /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a reference + /// to the specified global variable from exception handling information. /// virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const; - + MachineModuleInfo *MMI, unsigned Encoding) const; + + virtual const MCExpr * + getSymbolForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI, + unsigned Encoding) const; + + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; + protected: virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, @@ -231,7 +231,9 @@ ~TargetLoweringObjectFileELF(); virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); - + + const MCSection *getDataRelSection() const { return DataRelSection; } + /// getSectionForConstant - Given a constant with the SectionKind, return a /// section that it should be placed in. virtual const MCSection *getSectionForConstant(SectionKind Kind) const; @@ -244,6 +246,13 @@ virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; + + /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a reference + /// to the specified global variable from exception handling information. + /// + virtual const MCExpr * + getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI, unsigned Encoding) const; }; @@ -330,8 +339,7 @@ /// defaults to returning a stub reference. virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const; + MachineModuleInfo *MMI, unsigned Encoding) const; }; Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Feb 15 16:35:59 2010 @@ -68,15 +68,6 @@ }; } -// Specify if we should encode the LSDA pointer in the FDE as 4- or 8-bytes. -namespace DwarfLSDAEncoding { - enum Encoding { - Default, - FourByte, - EightByte - }; -} - //===----------------------------------------------------------------------===// /// /// TargetMachine - Primary interface to the complete machine description for @@ -179,20 +170,6 @@ /// is false. static void setAsmVerbosityDefault(bool); - /// getLSDAEncoding - Returns the LSDA pointer encoding. The choices are - /// 4-byte, 8-byte, and target default. The CIE is hard-coded to indicate that - /// the LSDA pointer in the FDE section is an "sdata4", and should be encoded - /// as a 4-byte pointer by default. However, some systems may require a - /// different size due to bugs or other conditions. We will default to a - /// 4-byte encoding unless the system tells us otherwise. - /// - /// FIXME: This call-back isn't good! We should be using the correct encoding - /// regardless of the system. However, there are some systems which have bugs - /// that prevent this from occuring. - virtual DwarfLSDAEncoding::Encoding getLSDAEncoding() const { - return DwarfLSDAEncoding::Default; - } - /// CodeGenFileType - These enums are meant to be passed into /// addPassesToEmitFile to indicate what type of file to emit, and returned by /// it to indicate what type of file could actually be made. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Mon Feb 15 16:35:59 2010 @@ -50,26 +50,6 @@ delete ExceptionTimer; } -/// SizeOfEncodedValue - Return the size of the encoding in bytes. -unsigned DwarfException::SizeOfEncodedValue(unsigned Encoding) { - if (Encoding == dwarf::DW_EH_PE_omit) - return 0; - - switch (Encoding & 0x07) { - case dwarf::DW_EH_PE_absptr: - return TD->getPointerSize(); - case dwarf::DW_EH_PE_udata2: - return 2; - case dwarf::DW_EH_PE_udata4: - return 4; - case dwarf::DW_EH_PE_udata8: - return 8; - } - - assert(0 && "Invalid encoded value."); - return 0; -} - /// CreateLabelDiff - Emit a label and subtract it from the expression we /// already have. This is equivalent to emitting "foo - .", but we have to emit /// the label for "." directly. @@ -100,7 +80,7 @@ TD->getPointerSize() : -TD->getPointerSize(); const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); - + // Begin eh frame section. Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); @@ -128,30 +108,16 @@ // The personality presence indicates that language specific information will // show up in the eh frame. Find out how we are supposed to lower the // personality function reference: - const MCExpr *PersonalityRef = 0; - bool IsPersonalityIndirect = false, IsPersonalityPCRel = false; - if (PersonalityFn) { - // FIXME: HANDLE STATIC CODEGEN MODEL HERE. - - // In non-static mode, ask the object file how to represent this reference. - PersonalityRef = - TLOF.getSymbolForDwarfGlobalReference(PersonalityFn, Asm->Mang, - Asm->MMI, - IsPersonalityIndirect, - IsPersonalityPCRel); - } - - unsigned PerEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; - if (IsPersonalityIndirect) - PerEncoding |= dwarf::DW_EH_PE_indirect; - unsigned LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; - unsigned FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; + + unsigned LSDAEncoding = TLOF.getLSDAEncoding(); + unsigned FDEEncoding = TLOF.getFDEEncoding(); + unsigned PerEncoding = TLOF.getPersonalityEncoding(); char Augmentation[6] = { 0 }; unsigned AugmentationSize = 0; char *APtr = Augmentation + 1; - if (PersonalityRef) { + if (PersonalityFn) { // There is a personality function. *APtr++ = 'P'; AugmentationSize += 1 + SizeOfEncodedValue(PerEncoding); @@ -182,19 +148,16 @@ EOL("CIE Return Address Column"); EmitULEB128(AugmentationSize, "Augmentation Size"); - EmitEncodingByte(PerEncoding, "Personality"); // If there is a personality, we need to indicate the function's location. - if (PersonalityRef) { - if (!IsPersonalityPCRel) - PersonalityRef = CreateLabelDiff(PersonalityRef, "personalityref_addr", - Index); - - O << MAI->getData32bitsDirective() << *PersonalityRef; + if (PersonalityFn) { + EmitEncodingByte(PerEncoding, "Personality"); + EmitReference(PersonalityFn, PerEncoding); EOL("Personality"); - - EmitEncodingByte(LSDAEncoding, "LSDA"); - EmitEncodingByte(FDEEncoding, "FDE"); + if (UsesLSDA[Index]) + EmitEncodingByte(LSDAEncoding, "LSDA"); + if (FDEEncoding != dwarf::DW_EH_PE_absptr) + EmitEncodingByte(FDEEncoding, "FDE"); } // Indicate locations of general callee saved registers in frame. @@ -216,8 +179,12 @@ "Should not emit 'available externally' functions at all"); const Function *TheFunc = EHFrameInfo.function; + const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); + + unsigned LSDAEncoding = TLOF.getLSDAEncoding(); + unsigned FDEEncoding = TLOF.getFDEEncoding(); - Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getEHFrameSection()); + Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); // Externally visible entry into the functions eh frame info. If the // corresponding function is static, this should not be externally visible. @@ -255,7 +222,8 @@ // EH frame header. EmitDifference("eh_frame_end", EHFrameInfo.Number, - "eh_frame_begin", EHFrameInfo.Number, true); + "eh_frame_begin", EHFrameInfo.Number, + true); EOL("Length of Frame Information Entry"); EmitLabel("eh_frame_begin", EHFrameInfo.Number); @@ -266,33 +234,23 @@ EOL("FDE CIE offset"); - EmitReference("eh_func_begin", EHFrameInfo.Number, true, true); + EmitReference("eh_func_begin", EHFrameInfo.Number, FDEEncoding); EOL("FDE initial location"); EmitDifference("eh_func_end", EHFrameInfo.Number, - "eh_func_begin", EHFrameInfo.Number, true); + "eh_func_begin", EHFrameInfo.Number, + SizeOfEncodedValue(FDEEncoding) == 4); EOL("FDE address range"); // If there is a personality and landing pads then point to the language // specific data area in the exception table. if (MMI->getPersonalities()[0] != NULL) { + unsigned Size = SizeOfEncodedValue(LSDAEncoding); - if (Asm->TM.getLSDAEncoding() != DwarfLSDAEncoding::EightByte) { - EmitULEB128(4, "Augmentation size"); - - if (EHFrameInfo.hasLandingPads) - EmitReference("exception", EHFrameInfo.Number, true, true); - else - Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/); - } else { - EmitULEB128(TD->getPointerSize(), "Augmentation size"); - - if (EHFrameInfo.hasLandingPads) { - EmitReference("exception", EHFrameInfo.Number, true, false); - } else { - Asm->OutStreamer.EmitIntValue(0, TD->getPointerSize(), - 0/*addrspace*/); - } - } + EmitULEB128(Size, "Augmentation size"); + if (EHFrameInfo.hasLandingPads) + EmitReference("exception", EHFrameInfo.Number, LSDAEncoding); + else + Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/); EOL("Language Specific Data Area"); } else { @@ -694,13 +652,13 @@ // Type infos. const MCSection *LSDASection = Asm->getObjFileLowering().getLSDASection(); - unsigned TTypeFormat; + unsigned TTypeEncoding; unsigned TypeFormatSize; if (!HaveTTData) { // For SjLj exceptions, if there is no TypeInfo, then we just explicitly say // that we're omitting that bit. - TTypeFormat = dwarf::DW_EH_PE_omit; + TTypeEncoding = dwarf::DW_EH_PE_omit; TypeFormatSize = SizeOfEncodedValue(dwarf::DW_EH_PE_absptr); } else { // Okay, we have actual filters or typeinfos to emit. As such, we need to @@ -730,14 +688,8 @@ // somewhere. This predicate should be moved to a shared location that is // in target-independent code. // - if (LSDASection->getKind().isWriteable() || - Asm->TM.getRelocationModel() == Reloc::Static) - TTypeFormat = dwarf::DW_EH_PE_absptr; - else - TTypeFormat = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | - dwarf::DW_EH_PE_sdata4; - - TypeFormatSize = SizeOfEncodedValue(TTypeFormat); + TTypeEncoding = Asm->getObjFileLowering().getTTypeEncoding(); + TypeFormatSize = SizeOfEncodedValue(TTypeEncoding); } // Begin the exception table. @@ -788,7 +740,7 @@ // Emit the header. EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart"); - EmitEncodingByte(TTypeFormat, "@TType"); + EmitEncodingByte(TTypeEncoding, "@TType"); if (HaveTTData) EmitULEB128(TyOffset, "@TType base offset"); @@ -911,12 +863,12 @@ for (std::vector::const_reverse_iterator I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) { const GlobalVariable *GV = *I; - PrintRelDirective(); if (GV) { - O << *Asm->GetGlobalValueSymbol(GV); + EmitReference(GV, TTypeEncoding); EOL("TypeInfo"); } else { + PrintRelDirective(); O << "0x0"; EOL(""); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Mon Feb 15 16:35:59 2010 @@ -76,9 +76,6 @@ /// ExceptionTimer - Timer for the Dwarf exception writer. Timer *ExceptionTimer; - /// SizeOfEncodedValue - Return the size of the encoding in bytes. - unsigned SizeOfEncodedValue(unsigned Encoding); - /// EmitCIE - Emit a Common Information Entry (CIE). This holds information /// that is shared among many Frame Description Entries. There is at least /// one CIE in every non-empty .debug_frame section. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Mon Feb 15 16:35:59 2010 @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // Emit general DWARF directives. -// +// //===----------------------------------------------------------------------===// #include "DwarfPrinter.h" @@ -18,13 +18,17 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" +#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/ADT/SmallString.h" using namespace llvm; DwarfPrinter::DwarfPrinter(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T, @@ -33,6 +37,26 @@ RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL), SubprogramCount(0), Flavor(flavor), SetCounter(1) {} +/// SizeOfEncodedValue - Return the size of the encoding in bytes. +unsigned DwarfPrinter::SizeOfEncodedValue(unsigned Encoding) const { + if (Encoding == dwarf::DW_EH_PE_omit) + return 0; + + switch (Encoding & 0x07) { + case dwarf::DW_EH_PE_absptr: + return TD->getPointerSize(); + case dwarf::DW_EH_PE_udata2: + return 2; + case dwarf::DW_EH_PE_udata4: + return 4; + case dwarf::DW_EH_PE_udata8: + return 8; + } + + assert(0 && "Invalid encoded value."); + return 0; +} + void DwarfPrinter::PrintRelDirective(bool Force32Bit, bool isInSection) const { if (isInSection && MAI->getDwarfSectionOffsetDirective()) O << MAI->getDwarfSectionOffsetDirective(); @@ -42,6 +66,14 @@ O << MAI->getData64bitsDirective(); } +void DwarfPrinter::PrintRelDirective(unsigned Encoding) const { + unsigned Size = SizeOfEncodedValue(Encoding); + assert((Size == 4 || Size == 8) && "Do not support other types or rels!"); + + O << (Size == 4 ? + MAI->getData32bitsDirective() : MAI->getData64bitsDirective()); +} + /// EOL - Print a newline character to asm stream. If a comment is present /// then it will be printed first. Comments should not contain '\n'. void DwarfPrinter::EOL(const Twine &Comment) const { @@ -195,6 +227,31 @@ if (IsPCRelative) O << "-" << MAI->getPCSymbol(); } +void DwarfPrinter::EmitReference(const char *Tag, unsigned Number, + unsigned Encoding) const { + SmallString<64> Name; + raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() + << Tag << Number; + + MCSymbol *Sym = Asm->OutContext.GetOrCreateSymbol(Name.str()); + EmitReference(Sym, Encoding); +} + +void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const { + const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); + + PrintRelDirective(Encoding); + O << *TLOF.getSymbolForDwarfReference(Sym, Asm->MMI, Encoding);; +} + +void DwarfPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const { + const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); + + PrintRelDirective(Encoding); + O << *TLOF.getSymbolForDwarfGlobalReference(GV, Asm->Mang, + Asm->MMI, Encoding);; +} + /// EmitDifference - Emit the difference between two labels. If this assembler /// supports .set, we emit a .set of a temporary and then use it in the .word. void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi, Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.h Mon Feb 15 16:35:59 2010 @@ -28,6 +28,7 @@ class MCAsmInfo; class TargetData; class TargetRegisterInfo; +class GlobalValue; class MCSymbol; class Twine; @@ -85,6 +86,10 @@ const MCAsmInfo *getMCAsmInfo() const { return MAI; } const TargetData *getTargetData() const { return TD; } + /// SizeOfEncodedValue - Return the size of the encoding in bytes. + unsigned SizeOfEncodedValue(unsigned Encoding) const; + + void PrintRelDirective(unsigned Encoding) const; void PrintRelDirective(bool Force32Bit = false, bool isInSection = false) const; @@ -140,6 +145,10 @@ void EmitReference(const MCSymbol *Sym, bool IsPCRelative = false, bool Force32Bit = false) const; + void EmitReference(const char *Tag, unsigned Number, unsigned Encoding) const; + void EmitReference(const MCSymbol *Sym, unsigned Encoding) const; + void EmitReference(const GlobalValue *GV, unsigned Encoding) const; + /// EmitDifference - Emit the difference between two labels. void EmitDifference(const DWLabel &LabelHi, const DWLabel &LabelLo, bool IsSmall = false) { Modified: llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineModuleInfoImpls.cpp Mon Feb 15 16:35:59 2010 @@ -22,7 +22,7 @@ // Out of line virtual method. void MachineModuleInfoMachO::Anchor() {} - +void MachineModuleInfoELF::Anchor() {} static int SortSymbolPair(const void *LHS, const void *RHS) { const MCSymbol *LHSS = @@ -34,10 +34,11 @@ /// GetSortedStubs - Return the entries from a DenseMap in a deterministic /// sorted orer. -MachineModuleInfoMachO::SymbolListTy -MachineModuleInfoMachO::GetSortedStubs(const DenseMap &Map) { - MachineModuleInfoMachO::SymbolListTy List(Map.begin(), Map.end()); +MachineModuleInfoImpl::SymbolListTy +MachineModuleInfoImpl::GetSortedStubs(const DenseMap &Map) { + MachineModuleInfoImpl::SymbolListTy List(Map.begin(), Map.end()); + if (!List.empty()) qsort(&List[0], List.size(), sizeof(List[0]), SortSymbolPair); return List; Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp Mon Feb 15 16:35:59 2010 @@ -115,32 +115,3 @@ return false; } - -/// getLSDAEncoding - Returns the LSDA pointer encoding. The choices are 4-byte, -/// 8-byte, and target default. The CIE is hard-coded to indicate that the LSDA -/// pointer in the FDE section is an "sdata4", and should be encoded as a 4-byte -/// pointer by default. However, some systems may require a different size due -/// to bugs or other conditions. We will default to a 4-byte encoding unless the -/// system tells us otherwise. -/// -/// The issue is when the CIE says their is an LSDA. That mandates that every -/// FDE have an LSDA slot. But if the function does not need an LSDA. There -/// needs to be some way to signify there is none. The LSDA is encoded as -/// pc-rel. But you don't look for some magic value after adding the pc. You -/// have to look for a zero before adding the pc. The problem is that the size -/// of the zero to look for depends on the encoding. The unwinder bug in SL is -/// that it always checks for a pointer-size zero. So on x86_64 it looks for 8 -/// bytes of zero. If you have an LSDA, it works fine since the 8-bytes are -/// non-zero so it goes ahead and then reads the value based on the encoding. -/// But if you use sdata4 and there is no LSDA, then the test for zero gives a -/// false negative and the unwinder thinks there is an LSDA. -/// -/// FIXME: This call-back isn't good! We should be using the correct encoding -/// regardless of the system. However, there are some systems which have bugs -/// that prevent this from occuring. -DwarfLSDAEncoding::Encoding PPCTargetMachine::getLSDAEncoding() const { - if (Subtarget.isDarwin() && Subtarget.getDarwinVers() != 10) - return DwarfLSDAEncoding::Default; - - return DwarfLSDAEncoding::EightByte; -} Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.h Mon Feb 15 16:35:59 2010 @@ -57,18 +57,6 @@ return InstrItins; } - /// getLSDAEncoding - Returns the LSDA pointer encoding. The choices are - /// 4-byte, 8-byte, and target default. The CIE is hard-coded to indicate that - /// the LSDA pointer in the FDE section is an "sdata4", and should be encoded - /// as a 4-byte pointer by default. However, some systems may require a - /// different size due to bugs or other conditions. We will default to a - /// 4-byte encoding unless the system tells us otherwise. - /// - /// FIXME: This call-back isn't good! We should be using the correct encoding - /// regardless of the system. However, there are some systems which have bugs - /// that prevent this from occuring. - virtual DwarfLSDAEncoding::Encoding getLSDAEncoding() const; - // Pass Pipeline Configuration virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel); Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Feb 15 16:35:59 2010 @@ -17,6 +17,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/GlobalVariable.h" +#include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSectionMachO.h" @@ -26,6 +27,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" @@ -289,32 +291,56 @@ } /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a -/// pc-relative reference to the specified global variable from exception -/// handling information. In addition to the symbol, this returns -/// by-reference: -/// -/// IsIndirect - True if the returned symbol is actually a stub that contains -/// the address of the symbol, false if the symbol is the global itself. -/// -/// IsPCRel - True if the symbol reference is already pc-relative, false if -/// the caller needs to subtract off the address of the reference from the -/// symbol. -/// +/// reference to the specified global variable from exception +/// handling information. const MCExpr *TargetLoweringObjectFile:: getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const { - // The generic implementation of this just returns a direct reference to the - // symbol. - IsIndirect = false; - IsPCRel = false; - + MachineModuleInfo *MMI, unsigned Encoding) const { // FIXME: Use GetGlobalValueSymbol. SmallString<128> Name; Mang->getNameWithPrefix(Name, GV, false); - return MCSymbolRefExpr::Create(Name.str(), getContext()); + const MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); + + return getSymbolForDwarfReference(Sym, MMI, Encoding); +} + +const MCExpr *TargetLoweringObjectFile:: +getSymbolForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI, + unsigned Encoding) const { + const MCExpr *Res = MCSymbolRefExpr::Create(Sym, getContext()); + + switch (Encoding & 0xF0) { + default: + llvm_report_error("Do not support this DWARF encoding yet!"); + break; + case dwarf::DW_EH_PE_absptr: + // Do nothing special + break; + case dwarf::DW_EH_PE_pcrel: + // FIXME: PCSymbol + const MCExpr *PC = MCSymbolRefExpr::Create(".", getContext()); + Res = MCBinaryExpr::CreateSub(Res, PC, getContext()); + break; + } + + return Res; +} + +unsigned TargetLoweringObjectFile::getPersonalityEncoding() const { + return dwarf::DW_EH_PE_absptr; +} + +unsigned TargetLoweringObjectFile::getLSDAEncoding() const { + return dwarf::DW_EH_PE_absptr; +} + +unsigned TargetLoweringObjectFile::getFDEEncoding() const { + return dwarf::DW_EH_PE_absptr; } +unsigned TargetLoweringObjectFile::getTTypeEncoding() const { + return dwarf::DW_EH_PE_absptr; +} //===----------------------------------------------------------------------===// // ELF @@ -671,6 +697,35 @@ return DataRelROSection; } +const MCExpr *TargetLoweringObjectFileELF:: +getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI, unsigned Encoding) const { + + if (Encoding & dwarf::DW_EH_PE_indirect) { + MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo(); + + SmallString<128> Name; + Mang->getNameWithPrefix(Name, GV, true); + + // Add information about the stub reference to ELFMMI so that the stub + // gets emitted by the asmprinter. + MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); + MCSymbol *&StubSym = ELFMMI.getGVStubEntry(Sym); + if (StubSym == 0) { + Name.clear(); + Mang->getNameWithPrefix(Name, GV, false); + StubSym = getContext().GetOrCreateSymbol(Name.str()); + } + + return TargetLoweringObjectFile:: + getSymbolForDwarfReference(Sym, MMI, + Encoding & ~dwarf::DW_EH_PE_indirect); + } + + return TargetLoweringObjectFile:: + getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding); +} + //===----------------------------------------------------------------------===// // MachO //===----------------------------------------------------------------------===// @@ -987,16 +1042,22 @@ const MCExpr *TargetLoweringObjectFileMachO:: getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const { + MachineModuleInfo *MMI, unsigned Encoding) const { // The mach-o version of this method defaults to returning a stub reference. - IsIndirect = true; - IsPCRel = false; - - SmallString<128> Name; - Mang->getNameWithPrefix(Name, GV, true); - Name += "$non_lazy_ptr"; - return MCSymbolRefExpr::Create(Name.str(), getContext()); + + if (Encoding & dwarf::DW_EH_PE_indirect) { + SmallString<128> Name; + Mang->getNameWithPrefix(Name, GV, true); + Name += "$non_lazy_ptr"; + MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); + + return TargetLoweringObjectFile:: + getSymbolForDwarfReference(Sym, MMI, + Encoding & ~dwarf::DW_EH_PE_indirect); + } + + return TargetLoweringObjectFile:: + getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding); } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Mon Feb 15 16:35:59 2010 @@ -603,6 +603,28 @@ } } } + + if (Subtarget->isTargetELF()) { + TargetLoweringObjectFileELF &TLOFELF = + static_cast(getObjFileLowering()); + + MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo(); + + // Output stubs for external and common global variables. + MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList(); + if (!Stubs.empty()) { + OutStreamer.SwitchSection(TLOFELF.getDataRelSection()); + const TargetData *TD = TM.getTargetData(); + + for (unsigned i = 0, e = Stubs.size(); i != e; ++i) + O << *Stubs[i].first << ":\n" + << (TD->getPointerSize() == 8 ? + MAI->getData64bitsDirective() : MAI->getData32bitsDirective()) + << *Stubs[i].second << '\n'; + + Stubs.clear(); + } + } } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Feb 15 16:35:59 2010 @@ -75,13 +75,14 @@ return new X8664_MachoTargetObjectFile(); return new X8632_MachoTargetObjectFile(); case X86Subtarget::isELF: - return new TargetLoweringObjectFileELF(); + if (TM.getSubtarget().is64Bit()) + return new X8664_ELFTargetObjectFile(TM); + return new X8632_ELFTargetObjectFile(TM); case X86Subtarget::isMingw: case X86Subtarget::isCygwin: case X86Subtarget::isWindows: return new TargetLoweringObjectFileCOFF(); } - } X86TargetLowering::X86TargetLowering(X86TargetMachine &TM) Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Feb 15 16:35:59 2010 @@ -199,32 +199,3 @@ else setCodeModel(CodeModel::Small); } - -/// getLSDAEncoding - Returns the LSDA pointer encoding. The choices are 4-byte, -/// 8-byte, and target default. The CIE is hard-coded to indicate that the LSDA -/// pointer in the FDE section is an "sdata4", and should be encoded as a 4-byte -/// pointer by default. However, some systems may require a different size due -/// to bugs or other conditions. We will default to a 4-byte encoding unless the -/// system tells us otherwise. -/// -/// The issue is when the CIE says their is an LSDA. That mandates that every -/// FDE have an LSDA slot. But if the function does not need an LSDA. There -/// needs to be some way to signify there is none. The LSDA is encoded as -/// pc-rel. But you don't look for some magic value after adding the pc. You -/// have to look for a zero before adding the pc. The problem is that the size -/// of the zero to look for depends on the encoding. The unwinder bug in SL is -/// that it always checks for a pointer-size zero. So on x86_64 it looks for 8 -/// bytes of zero. If you have an LSDA, it works fine since the 8-bytes are -/// non-zero so it goes ahead and then reads the value based on the encoding. -/// But if you use sdata4 and there is no LSDA, then the test for zero gives a -/// false negative and the unwinder thinks there is an LSDA. -/// -/// FIXME: This call-back isn't good! We should be using the correct encoding -/// regardless of the system. However, there are some systems which have bugs -/// that prevent this from occuring. -DwarfLSDAEncoding::Encoding X86TargetMachine::getLSDAEncoding() const { - if (Subtarget.isTargetDarwin() && Subtarget.getDarwinVers() != 10) - return DwarfLSDAEncoding::Default; - - return DwarfLSDAEncoding::EightByte; -} Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.h Mon Feb 15 16:35:59 2010 @@ -62,18 +62,6 @@ return Subtarget.isTargetELF() ? &ELFWriterInfo : 0; } - /// getLSDAEncoding - Returns the LSDA pointer encoding. The choices are - /// 4-byte, 8-byte, and target default. The CIE is hard-coded to indicate that - /// the LSDA pointer in the FDE section is an "sdata4", and should be encoded - /// as a 4-byte pointer by default. However, some systems may require a - /// different size due to bugs or other conditions. We will default to a - /// 4-byte encoding unless the system tells us otherwise. - /// - /// FIXME: This call-back isn't good! We should be using the correct encoding - /// regardless of the system. However, there are some systems which have bugs - /// that prevent this from occuring. - virtual DwarfLSDAEncoding::Encoding getLSDAEncoding() const; - // Set up the pass pipeline. virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel); Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Mon Feb 15 16:35:59 2010 @@ -7,61 +7,177 @@ // //===----------------------------------------------------------------------===// -#include "X86TargetObjectFile.h" #include "X86MCTargetExpr.h" +#include "X86TargetObjectFile.h" +#include "X86TargetMachine.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/MC/MCContext.h" #include "llvm/Target/Mangler.h" #include "llvm/ADT/SmallString.h" +#include "llvm/Support/Dwarf.h" using namespace llvm; +using namespace dwarf; const MCExpr *X8632_MachoTargetObjectFile:: getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const { + MachineModuleInfo *MMI, unsigned Encoding) const { // The mach-o version of this method defaults to returning a stub reference. - IsIndirect = true; - IsPCRel = false; - - - MachineModuleInfoMachO &MachOMMI = - MMI->getObjFileInfo(); - - // FIXME: Use GetSymbolWithGlobalValueBase. - SmallString<128> Name; - Mang->getNameWithPrefix(Name, GV, true); - Name += "$non_lazy_ptr"; - - // Add information about the stub reference to MachOMMI so that the stub gets - // emitted by the asmprinter. - MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); - MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym); - if (StubSym == 0) { - Name.clear(); - Mang->getNameWithPrefix(Name, GV, false); - StubSym = getContext().GetOrCreateSymbol(Name.str()); + + if (Encoding & DW_EH_PE_indirect) { + MachineModuleInfoMachO &MachOMMI = + MMI->getObjFileInfo(); + + SmallString<128> Name; + Mang->getNameWithPrefix(Name, GV, true); + Name += "$non_lazy_ptr"; + + // Add information about the stub reference to MachOMMI so that the stub + // gets emitted by the asmprinter. + MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); + MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym); + if (StubSym == 0) { + Name.clear(); + Mang->getNameWithPrefix(Name, GV, false); + StubSym = getContext().GetOrCreateSymbol(Name.str()); + } + + return TargetLoweringObjectFile:: + getSymbolForDwarfReference(Sym, MMI, + Encoding & ~dwarf::DW_EH_PE_indirect); } - - return MCSymbolRefExpr::Create(Sym, getContext()); + + return TargetLoweringObjectFileMachO:: + getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding); } const MCExpr *X8664_MachoTargetObjectFile:: getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const { - + MachineModuleInfo *MMI, unsigned Encoding) const { + // On Darwin/X86-64, we can reference dwarf symbols with foo at GOTPCREL+4, which // is an indirect pc-relative reference. - IsIndirect = true; - IsPCRel = true; - - // FIXME: Use GetSymbolWithGlobalValueBase. - SmallString<128> Name; - Mang->getNameWithPrefix(Name, GV, false); + if ((Encoding & DW_EH_PE_indirect) && + (Encoding & DW_EH_PE_pcrel)) { + SmallString<128> Name; + Mang->getNameWithPrefix(Name, GV, false); const MCSymbol *Sym = getContext().CreateSymbol(Name); const MCExpr *Res = X86MCTargetExpr::Create(Sym, X86MCTargetExpr::GOTPCREL, getContext()); const MCExpr *Four = MCConstantExpr::Create(4, getContext()); return MCBinaryExpr::CreateAdd(Res, Four, getContext()); + } + + return TargetLoweringObjectFileMachO:: + getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding); +} + +unsigned X8632_ELFTargetObjectFile::getPersonalityEncoding() const { + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; + else + return DW_EH_PE_absptr; +} + +unsigned X8632_ELFTargetObjectFile::getLSDAEncoding() const { + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + else + return DW_EH_PE_absptr; +} + +unsigned X8632_ELFTargetObjectFile::getFDEEncoding() const { + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + else + return DW_EH_PE_absptr; +} + +unsigned X8632_ELFTargetObjectFile::getTTypeEncoding() const { + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; + else + return DW_EH_PE_absptr; } +unsigned X8664_ELFTargetObjectFile::getPersonalityEncoding() const { + CodeModel::Model Model = TM.getCodeModel(); + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_indirect | DW_EH_PE_pcrel | (Model == CodeModel::Small || + Model == CodeModel::Medium ? + DW_EH_PE_sdata4 : DW_EH_PE_sdata8); + + if (Model == CodeModel::Small || Model == CodeModel::Medium) + return DW_EH_PE_udata4; + + return DW_EH_PE_absptr; +} + +unsigned X8664_ELFTargetObjectFile::getLSDAEncoding() const { + CodeModel::Model Model = TM.getCodeModel(); + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_pcrel | (Model == CodeModel::Small ? + DW_EH_PE_sdata4 : DW_EH_PE_sdata8); + + if (Model == CodeModel::Small) + return DW_EH_PE_udata4; + + return DW_EH_PE_absptr; +} + +unsigned X8664_ELFTargetObjectFile::getFDEEncoding() const { + CodeModel::Model Model = TM.getCodeModel(); + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_pcrel | (Model == CodeModel::Small || + Model == CodeModel::Medium ? + DW_EH_PE_sdata4 : DW_EH_PE_sdata8); + + if (Model == CodeModel::Small || Model == CodeModel::Medium) + return DW_EH_PE_udata4; + + return DW_EH_PE_absptr; +} + +unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const { + CodeModel::Model Model = TM.getCodeModel(); + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_indirect | DW_EH_PE_pcrel | (Model == CodeModel::Small || + Model == CodeModel::Medium ? + DW_EH_PE_sdata4 : DW_EH_PE_sdata8); + + if (Model == CodeModel::Small) + return DW_EH_PE_udata4; + + return DW_EH_PE_absptr; +} + +unsigned X8632_MachoTargetObjectFile::getPersonalityEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8632_MachoTargetObjectFile::getLSDAEncoding() const { + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8632_MachoTargetObjectFile::getFDEEncoding() const { + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8632_MachoTargetObjectFile::getTTypeEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8664_MachoTargetObjectFile::getPersonalityEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8664_MachoTargetObjectFile::getLSDAEncoding() const { + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8664_MachoTargetObjectFile::getFDEEncoding() const { + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8664_MachoTargetObjectFile::getTTypeEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Mon Feb 15 16:35:59 2010 @@ -10,21 +10,26 @@ #ifndef LLVM_TARGET_X86_TARGETOBJECTFILE_H #define LLVM_TARGET_X86_TARGETOBJECTFILE_H +#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetLoweringObjectFile.h" namespace llvm { - + class X86TargetMachine; + /// X8632_MachoTargetObjectFile - This TLOF implementation is used for /// Darwin/x86-32. class X8632_MachoTargetObjectFile : public TargetLoweringObjectFileMachO { public: - + virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const; + MachineModuleInfo *MMI, unsigned Encoding) const; + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; }; - + /// X8664_MachoTargetObjectFile - This TLOF implementation is used for /// Darwin/x86-64. class X8664_MachoTargetObjectFile : public TargetLoweringObjectFileMachO { @@ -32,9 +37,35 @@ virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, - bool &IsIndirect, bool &IsPCRel) const; + MachineModuleInfo *MMI, unsigned Encoding) const; + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; + }; + + class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF { + const X86TargetMachine &TM; + public: + X8632_ELFTargetObjectFile(const X86TargetMachine &tm) + :TM(tm) { }; + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; }; + + class X8664_ELFTargetObjectFile : public TargetLoweringObjectFileELF { + const X86TargetMachine &TM; + public: + X8664_ELFTargetObjectFile(const X86TargetMachine &tm) + :TM(tm) { }; + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; + }; + } // end namespace llvm #endif Modified: llvm/trunk/test/CodeGen/Generic/2007-05-05-Personality.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/2007-05-05-Personality.ll?rev=96285&r1=96284&r2=96285&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Generic/2007-05-05-Personality.ll (original) +++ llvm/trunk/test/CodeGen/Generic/2007-05-05-Personality.ll Mon Feb 15 16:35:59 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i686-pc-linux-gnu -enable-eh -o - | grep zPLR +; RUN: llc < %s -mtriple=i686-pc-linux-gnu -enable-eh -o - | grep zPL @error = external global i8 ; [#uses=2] From asl at math.spbu.ru Mon Feb 15 16:36:26 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Feb 2010 22:36:26 -0000 Subject: [llvm-commits] [llvm] r96286 - /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Message-ID: <201002152236.o1FMaQEq024350@zion.cs.uiuc.edu> Author: asl Date: Mon Feb 15 16:36:26 2010 New Revision: 96286 URL: http://llvm.org/viewvc/llvm-project?rev=96286&view=rev Log: Add suffix for stubs, so we won't have name clashes with private symbols. Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=96286&r1=96285&r2=96286&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Feb 15 16:36:26 2010 @@ -706,6 +706,7 @@ SmallString<128> Name; Mang->getNameWithPrefix(Name, GV, true); + Name += ".DW.stub"; // Add information about the stub reference to ELFMMI so that the stub // gets emitted by the asmprinter. From asl at math.spbu.ru Mon Feb 15 16:36:41 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Feb 2010 22:36:41 -0000 Subject: [llvm-commits] [llvm] r96287 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Message-ID: <201002152236.o1FMafxJ024377@zion.cs.uiuc.edu> Author: asl Date: Mon Feb 15 16:36:41 2010 New Revision: 96287 URL: http://llvm.org/viewvc/llvm-project?rev=96287&view=rev Log: It turns out that we emitted completely wrong common EH frame since the early beginning! The "z" CIE augmentation mark indicates that there is an extra word containing the size of augmentation section. However, even for frames w/o any augmentation data we emitted size uleb! (this is the case of "unwinding through C code"). Thus frame moves information was emitterd completely wrong. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=96287&r1=96286&r2=96287&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Mon Feb 15 16:36:41 2010 @@ -147,13 +147,15 @@ Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true)); EOL("CIE Return Address Column"); - EmitULEB128(AugmentationSize, "Augmentation Size"); + if (Augmentation[0]) { + EmitULEB128(AugmentationSize, "Augmentation Size"); - // If there is a personality, we need to indicate the function's location. - if (PersonalityFn) { - EmitEncodingByte(PerEncoding, "Personality"); - EmitReference(PersonalityFn, PerEncoding); - EOL("Personality"); + // If there is a personality, we need to indicate the function's location. + if (PersonalityFn) { + EmitEncodingByte(PerEncoding, "Personality"); + EmitReference(PersonalityFn, PerEncoding); + EOL("Personality"); + } if (UsesLSDA[Index]) EmitEncodingByte(LSDAEncoding, "LSDA"); if (FDEEncoding != dwarf::DW_EH_PE_absptr) From asl at math.spbu.ru Mon Feb 15 16:37:53 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Feb 2010 22:37:53 -0000 Subject: [llvm-commits] [llvm] r96288 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Target/ lib/CodeGen/ lib/Target/ lib/Target/ARM/ lib/Target/ARM/AsmPrinter/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PowerPC/ lib/Target/PowerPC/AsmPrinter/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ lib/Target/XCore/ Message-ID: <201002152237.o1FMbsZU024452@zion.cs.uiuc.edu> Author: asl Date: Mon Feb 15 16:37:53 2010 New Revision: 96288 URL: http://llvm.org/viewvc/llvm-project?rev=96288&view=rev Log: Move TLOF implementations to libCodegen to resolve layering violation. Added: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp - copied, changed from r96287, llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h Added: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=96288&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (added) +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Mon Feb 15 16:37:53 2010 @@ -0,0 +1,202 @@ +//==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements classes used to handle lowerings specific to common +// object file formats. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H +#define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/MC/SectionKind.h" +#include "llvm/Target/TargetLoweringObjectFile.h" + +namespace llvm { + class MachineModuleInfo; + class Mangler; + class MCAsmInfo; + class MCExpr; + class MCSection; + class MCSectionMachO; + class MCSymbol; + class MCContext; + class GlobalValue; + class TargetMachine; + + +class TargetLoweringObjectFileELF : public TargetLoweringObjectFile { + mutable void *UniquingMap; +protected: + /// TLSDataSection - Section directive for Thread Local data. + /// + const MCSection *TLSDataSection; // Defaults to ".tdata". + + /// TLSBSSSection - Section directive for Thread Local uninitialized data. + /// Null if this target doesn't support a BSS section. + /// + const MCSection *TLSBSSSection; // Defaults to ".tbss". + + const MCSection *DataRelSection; + const MCSection *DataRelLocalSection; + const MCSection *DataRelROSection; + const MCSection *DataRelROLocalSection; + + const MCSection *MergeableConst4Section; + const MCSection *MergeableConst8Section; + const MCSection *MergeableConst16Section; + +protected: + const MCSection *getELFSection(StringRef Section, unsigned Type, + unsigned Flags, SectionKind Kind, + bool IsExplicit = false) const; +public: + TargetLoweringObjectFileELF() : UniquingMap(0) {} + ~TargetLoweringObjectFileELF(); + + virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); + + const MCSection *getDataRelSection() const { return DataRelSection; } + + /// getSectionForConstant - Given a constant with the SectionKind, return a + /// section that it should be placed in. + virtual const MCSection *getSectionForConstant(SectionKind Kind) const; + + + virtual const MCSection * + getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; + + virtual const MCSection * + SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; + + /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a reference + /// to the specified global variable from exception handling information. + /// + virtual const MCExpr * + getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI, unsigned Encoding) const; +}; + + + +class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { + mutable void *UniquingMap; + + const MCSection *CStringSection; + const MCSection *UStringSection; + const MCSection *TextCoalSection; + const MCSection *ConstTextCoalSection; + const MCSection *ConstDataCoalSection; + const MCSection *ConstDataSection; + const MCSection *DataCoalSection; + const MCSection *DataCommonSection; + const MCSection *DataBSSSection; + const MCSection *FourByteConstantSection; + const MCSection *EightByteConstantSection; + const MCSection *SixteenByteConstantSection; + + const MCSection *LazySymbolPointerSection; + const MCSection *NonLazySymbolPointerSection; +public: + TargetLoweringObjectFileMachO() : UniquingMap(0) {} + ~TargetLoweringObjectFileMachO(); + + virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); + + virtual const MCSection * + SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; + + virtual const MCSection * + getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; + + virtual const MCSection *getSectionForConstant(SectionKind Kind) const; + + /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively + /// decide not to emit the UsedDirective for some symbols in llvm.used. + /// FIXME: REMOVE this (rdar://7071300) + virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, + Mangler *) const; + + /// getMachOSection - Return the MCSection for the specified mach-o section. + /// This requires the operands to be valid. + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, + unsigned TypeAndAttributes, + SectionKind K) const { + return getMachOSection(Segment, Section, TypeAndAttributes, 0, K); + } + const MCSectionMachO *getMachOSection(StringRef Segment, + StringRef Section, + unsigned TypeAndAttributes, + unsigned Reserved2, + SectionKind K) const; + + /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak + /// text symbols into. + const MCSection *getTextCoalSection() const { + return TextCoalSection; + } + + /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section + /// we put weak read-only symbols into. + const MCSection *getConstTextCoalSection() const { + return ConstTextCoalSection; + } + + /// getLazySymbolPointerSection - Return the section corresponding to + /// the .lazy_symbol_pointer directive. + const MCSection *getLazySymbolPointerSection() const { + return LazySymbolPointerSection; + } + + /// getNonLazySymbolPointerSection - Return the section corresponding to + /// the .non_lazy_symbol_pointer directive. + const MCSection *getNonLazySymbolPointerSection() const { + return NonLazySymbolPointerSection; + } + + /// getSymbolForDwarfGlobalReference - The mach-o version of this method + /// defaults to returning a stub reference. + virtual const MCExpr * + getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI, unsigned Encoding) const; +}; + + + +class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile { + mutable void *UniquingMap; +public: + TargetLoweringObjectFileCOFF() : UniquingMap(0) {} + ~TargetLoweringObjectFileCOFF(); + + virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); + + virtual const MCSection * + getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; + + virtual const MCSection * + SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler *Mang, const TargetMachine &TM) const; + + /// getCOFFSection - Return the MCSection for the specified COFF section. + /// FIXME: Switch this to a semantic view eventually. + const MCSection *getCOFFSection(StringRef Name, bool isDirective, + SectionKind K) const; +}; + +} // end namespace llvm + +#endif Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Mon Feb 15 16:37:53 2010 @@ -197,174 +197,6 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; }; - - - - -class TargetLoweringObjectFileELF : public TargetLoweringObjectFile { - mutable void *UniquingMap; -protected: - /// TLSDataSection - Section directive for Thread Local data. - /// - const MCSection *TLSDataSection; // Defaults to ".tdata". - - /// TLSBSSSection - Section directive for Thread Local uninitialized data. - /// Null if this target doesn't support a BSS section. - /// - const MCSection *TLSBSSSection; // Defaults to ".tbss". - - const MCSection *DataRelSection; - const MCSection *DataRelLocalSection; - const MCSection *DataRelROSection; - const MCSection *DataRelROLocalSection; - - const MCSection *MergeableConst4Section; - const MCSection *MergeableConst8Section; - const MCSection *MergeableConst16Section; - -protected: - const MCSection *getELFSection(StringRef Section, unsigned Type, - unsigned Flags, SectionKind Kind, - bool IsExplicit = false) const; -public: - TargetLoweringObjectFileELF() : UniquingMap(0) {} - ~TargetLoweringObjectFileELF(); - - virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); - - const MCSection *getDataRelSection() const { return DataRelSection; } - - /// getSectionForConstant - Given a constant with the SectionKind, return a - /// section that it should be placed in. - virtual const MCSection *getSectionForConstant(SectionKind Kind) const; - - - virtual const MCSection * - getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const; - - virtual const MCSection * - SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const; - - /// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a reference - /// to the specified global variable from exception handling information. - /// - virtual const MCExpr * - getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, unsigned Encoding) const; -}; - - - -class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { - mutable void *UniquingMap; - - const MCSection *CStringSection; - const MCSection *UStringSection; - const MCSection *TextCoalSection; - const MCSection *ConstTextCoalSection; - const MCSection *ConstDataCoalSection; - const MCSection *ConstDataSection; - const MCSection *DataCoalSection; - const MCSection *DataCommonSection; - const MCSection *DataBSSSection; - const MCSection *FourByteConstantSection; - const MCSection *EightByteConstantSection; - const MCSection *SixteenByteConstantSection; - - const MCSection *LazySymbolPointerSection; - const MCSection *NonLazySymbolPointerSection; -public: - TargetLoweringObjectFileMachO() : UniquingMap(0) {} - ~TargetLoweringObjectFileMachO(); - - virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); - - virtual const MCSection * - SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const; - - virtual const MCSection * - getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const; - - virtual const MCSection *getSectionForConstant(SectionKind Kind) const; - - /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively - /// decide not to emit the UsedDirective for some symbols in llvm.used. - /// FIXME: REMOVE this (rdar://7071300) - virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, - Mangler *) const; - - /// getMachOSection - Return the MCSection for the specified mach-o section. - /// This requires the operands to be valid. - const MCSectionMachO *getMachOSection(StringRef Segment, - StringRef Section, - unsigned TypeAndAttributes, - SectionKind K) const { - return getMachOSection(Segment, Section, TypeAndAttributes, 0, K); - } - const MCSectionMachO *getMachOSection(StringRef Segment, - StringRef Section, - unsigned TypeAndAttributes, - unsigned Reserved2, - SectionKind K) const; - - /// getTextCoalSection - Return the "__TEXT,__textcoal_nt" section we put weak - /// text symbols into. - const MCSection *getTextCoalSection() const { - return TextCoalSection; - } - - /// getConstTextCoalSection - Return the "__TEXT,__const_coal" section - /// we put weak read-only symbols into. - const MCSection *getConstTextCoalSection() const { - return ConstTextCoalSection; - } - - /// getLazySymbolPointerSection - Return the section corresponding to - /// the .lazy_symbol_pointer directive. - const MCSection *getLazySymbolPointerSection() const { - return LazySymbolPointerSection; - } - - /// getNonLazySymbolPointerSection - Return the section corresponding to - /// the .non_lazy_symbol_pointer directive. - const MCSection *getNonLazySymbolPointerSection() const { - return NonLazySymbolPointerSection; - } - - /// getSymbolForDwarfGlobalReference - The mach-o version of this method - /// defaults to returning a stub reference. - virtual const MCExpr * - getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, unsigned Encoding) const; -}; - - - -class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile { - mutable void *UniquingMap; -public: - TargetLoweringObjectFileCOFF() : UniquingMap(0) {} - ~TargetLoweringObjectFileCOFF(); - - virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); - - virtual const MCSection * - getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const; - - virtual const MCSection * - SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const; - - /// getCOFFSection - Return the MCSection for the specified COFF section. - /// FIXME: Switch this to a semantic view eventually. - const MCSection *getCOFFSection(StringRef Name, bool isDirective, - SectionKind K) const; -}; } // end namespace llvm Copied: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (from r96287, llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?p2=llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp&p1=llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp&r1=96287&r2=96288&rev=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Mon Feb 15 16:37:53 2010 @@ -1,4 +1,4 @@ -//===-- llvm/Target/TargetLoweringObjectFile.cpp - Object File Info -------===// +//===-- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info --===// // // The LLVM Compiler Infrastructure // @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" @@ -35,314 +35,6 @@ using namespace llvm; //===----------------------------------------------------------------------===// -// Generic Code -//===----------------------------------------------------------------------===// - -TargetLoweringObjectFile::TargetLoweringObjectFile() : Ctx(0) { - TextSection = 0; - DataSection = 0; - BSSSection = 0; - ReadOnlySection = 0; - StaticCtorSection = 0; - StaticDtorSection = 0; - LSDASection = 0; - EHFrameSection = 0; - - DwarfAbbrevSection = 0; - DwarfInfoSection = 0; - DwarfLineSection = 0; - DwarfFrameSection = 0; - DwarfPubNamesSection = 0; - DwarfPubTypesSection = 0; - DwarfDebugInlineSection = 0; - DwarfStrSection = 0; - DwarfLocSection = 0; - DwarfARangesSection = 0; - DwarfRangesSection = 0; - DwarfMacroInfoSection = 0; -} - -TargetLoweringObjectFile::~TargetLoweringObjectFile() { -} - -static bool isSuitableForBSS(const GlobalVariable *GV) { - Constant *C = GV->getInitializer(); - - // Must have zero initializer. - if (!C->isNullValue()) - return false; - - // Leave constant zeros in readonly constant sections, so they can be shared. - if (GV->isConstant()) - return false; - - // If the global has an explicit section specified, don't put it in BSS. - if (!GV->getSection().empty()) - return false; - - // If -nozero-initialized-in-bss is specified, don't ever use BSS. - if (NoZerosInBSS) - return false; - - // Otherwise, put it in BSS! - return true; -} - -/// IsNullTerminatedString - Return true if the specified constant (which is -/// known to have a type that is an array of 1/2/4 byte elements) ends with a -/// nul value and contains no other nuls in it. -static bool IsNullTerminatedString(const Constant *C) { - const ArrayType *ATy = cast(C->getType()); - - // First check: is we have constant array of i8 terminated with zero - if (const ConstantArray *CVA = dyn_cast(C)) { - if (ATy->getNumElements() == 0) return false; - - ConstantInt *Null = - dyn_cast(CVA->getOperand(ATy->getNumElements()-1)); - if (Null == 0 || Null->getZExtValue() != 0) - return false; // Not null terminated. - - // Verify that the null doesn't occur anywhere else in the string. - for (unsigned i = 0, e = ATy->getNumElements()-1; i != e; ++i) - // Reject constantexpr elements etc. - if (!isa(CVA->getOperand(i)) || - CVA->getOperand(i) == Null) - return false; - return true; - } - - // Another possibility: [1 x i8] zeroinitializer - if (isa(C)) - return ATy->getNumElements() == 1; - - return false; -} - -/// getKindForGlobal - This is a top-level target-independent classifier for -/// a global variable. Given an global variable and information from TM, it -/// classifies the global in a variety of ways that make various target -/// implementations simpler. The target implementation is free to ignore this -/// extra info of course. -SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, - const TargetMachine &TM){ - assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() && - "Can only be used for global definitions"); - - Reloc::Model ReloModel = TM.getRelocationModel(); - - // Early exit - functions should be always in text sections. - const GlobalVariable *GVar = dyn_cast(GV); - if (GVar == 0) - return SectionKind::getText(); - - // Handle thread-local data first. - if (GVar->isThreadLocal()) { - if (isSuitableForBSS(GVar)) - return SectionKind::getThreadBSS(); - return SectionKind::getThreadData(); - } - - // Variables with common linkage always get classified as common. - if (GVar->hasCommonLinkage()) - return SectionKind::getCommon(); - - // Variable can be easily put to BSS section. - if (isSuitableForBSS(GVar)) { - if (GVar->hasLocalLinkage()) - return SectionKind::getBSSLocal(); - else if (GVar->hasExternalLinkage()) - return SectionKind::getBSSExtern(); - return SectionKind::getBSS(); - } - - Constant *C = GVar->getInitializer(); - - // If the global is marked constant, we can put it into a mergable section, - // a mergable string section, or general .data if it contains relocations. - if (GVar->isConstant()) { - // If the initializer for the global contains something that requires a - // relocation, then we may have to drop this into a wriable data section - // even though it is marked const. - switch (C->getRelocationInfo()) { - default: assert(0 && "unknown relocation info kind"); - case Constant::NoRelocation: - // If initializer is a null-terminated string, put it in a "cstring" - // section of the right width. - if (const ArrayType *ATy = dyn_cast(C->getType())) { - if (const IntegerType *ITy = - dyn_cast(ATy->getElementType())) { - if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 || - ITy->getBitWidth() == 32) && - IsNullTerminatedString(C)) { - if (ITy->getBitWidth() == 8) - return SectionKind::getMergeable1ByteCString(); - if (ITy->getBitWidth() == 16) - return SectionKind::getMergeable2ByteCString(); - - assert(ITy->getBitWidth() == 32 && "Unknown width"); - return SectionKind::getMergeable4ByteCString(); - } - } - } - - // Otherwise, just drop it into a mergable constant section. If we have - // a section for this size, use it, otherwise use the arbitrary sized - // mergable section. - switch (TM.getTargetData()->getTypeAllocSize(C->getType())) { - case 4: return SectionKind::getMergeableConst4(); - case 8: return SectionKind::getMergeableConst8(); - case 16: return SectionKind::getMergeableConst16(); - default: return SectionKind::getMergeableConst(); - } - - case Constant::LocalRelocation: - // In static relocation model, the linker will resolve all addresses, so - // the relocation entries will actually be constants by the time the app - // starts up. However, we can't put this into a mergable section, because - // the linker doesn't take relocations into consideration when it tries to - // merge entries in the section. - if (ReloModel == Reloc::Static) - return SectionKind::getReadOnly(); - - // Otherwise, the dynamic linker needs to fix it up, put it in the - // writable data.rel.local section. - return SectionKind::getReadOnlyWithRelLocal(); - - case Constant::GlobalRelocations: - // In static relocation model, the linker will resolve all addresses, so - // the relocation entries will actually be constants by the time the app - // starts up. However, we can't put this into a mergable section, because - // the linker doesn't take relocations into consideration when it tries to - // merge entries in the section. - if (ReloModel == Reloc::Static) - return SectionKind::getReadOnly(); - - // Otherwise, the dynamic linker needs to fix it up, put it in the - // writable data.rel section. - return SectionKind::getReadOnlyWithRel(); - } - } - - // Okay, this isn't a constant. If the initializer for the global is going - // to require a runtime relocation by the dynamic linker, put it into a more - // specific section to improve startup time of the app. This coalesces these - // globals together onto fewer pages, improving the locality of the dynamic - // linker. - if (ReloModel == Reloc::Static) - return SectionKind::getDataNoRel(); - - switch (C->getRelocationInfo()) { - default: assert(0 && "unknown relocation info kind"); - case Constant::NoRelocation: - return SectionKind::getDataNoRel(); - case Constant::LocalRelocation: - return SectionKind::getDataRelLocal(); - case Constant::GlobalRelocations: - return SectionKind::getDataRel(); - } -} - -/// SectionForGlobal - This method computes the appropriate section to emit -/// the specified global variable or function definition. This should not -/// be passed external (or available externally) globals. -const MCSection *TargetLoweringObjectFile:: -SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, - const TargetMachine &TM) const { - // Select section name. - if (GV->hasSection()) - return getExplicitSectionGlobal(GV, Kind, Mang, TM); - - - // Use default section depending on the 'type' of global - return SelectSectionForGlobal(GV, Kind, Mang, TM); -} - - -// Lame default implementation. Calculate the section name for global. -const MCSection * -TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, - Mangler *Mang, - const TargetMachine &TM) const{ - assert(!Kind.isThreadLocal() && "Doesn't support TLS"); - - if (Kind.isText()) - return getTextSection(); - - if (Kind.isBSS() && BSSSection != 0) - return BSSSection; - - if (Kind.isReadOnly() && ReadOnlySection != 0) - return ReadOnlySection; - - return getDataSection(); -} - -/// getSectionForConstant - Given a mergable constant with the -/// specified size and relocation information, return a section that it -/// should be placed in. -const MCSection * -TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const { - if (Kind.isReadOnly() && ReadOnlySection != 0) - return ReadOnlySection; - - return DataSection; -} - -/// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a -/// reference to the specified global variable from exception -/// handling information. -const MCExpr *TargetLoweringObjectFile:: -getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, unsigned Encoding) const { - // FIXME: Use GetGlobalValueSymbol. - SmallString<128> Name; - Mang->getNameWithPrefix(Name, GV, false); - const MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); - - return getSymbolForDwarfReference(Sym, MMI, Encoding); -} - -const MCExpr *TargetLoweringObjectFile:: -getSymbolForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI, - unsigned Encoding) const { - const MCExpr *Res = MCSymbolRefExpr::Create(Sym, getContext()); - - switch (Encoding & 0xF0) { - default: - llvm_report_error("Do not support this DWARF encoding yet!"); - break; - case dwarf::DW_EH_PE_absptr: - // Do nothing special - break; - case dwarf::DW_EH_PE_pcrel: - // FIXME: PCSymbol - const MCExpr *PC = MCSymbolRefExpr::Create(".", getContext()); - Res = MCBinaryExpr::CreateSub(Res, PC, getContext()); - break; - } - - return Res; -} - -unsigned TargetLoweringObjectFile::getPersonalityEncoding() const { - return dwarf::DW_EH_PE_absptr; -} - -unsigned TargetLoweringObjectFile::getLSDAEncoding() const { - return dwarf::DW_EH_PE_absptr; -} - -unsigned TargetLoweringObjectFile::getFDEEncoding() const { - return dwarf::DW_EH_PE_absptr; -} - -unsigned TargetLoweringObjectFile::getTTypeEncoding() const { - return dwarf::DW_EH_PE_absptr; -} - -//===----------------------------------------------------------------------===// // ELF //===----------------------------------------------------------------------===// typedef StringMap ELFUniqueMapTy; Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Mon Feb 15 16:37:53 2010 @@ -10,7 +10,7 @@ #ifndef LLVM_TARGET_ARM_TARGETOBJECTFILE_H #define LLVM_TARGET_ARM_TARGETOBJECTFILE_H -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/MC/MCSectionELF.h" namespace llvm { @@ -24,7 +24,7 @@ if (TM.getSubtarget().isAAPCS_ABI()) { StaticCtorSection = - getELFSection(".init_array", MCSectionELF::SHT_INIT_ARRAY, + getELFSection(".init_array", MCSectionELF::SHT_INIT_ARRAY, MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, SectionKind::getDataRel()); StaticDtorSection = Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Feb 15 16:37:53 2010 @@ -30,6 +30,7 @@ #include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInst.h" @@ -37,7 +38,6 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" Modified: llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp Mon Feb 15 16:37:53 2010 @@ -21,7 +21,7 @@ #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Module.h" Modified: llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Mon Feb 15 16:37:53 2010 @@ -22,7 +22,7 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/SelectionDAG.h" -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/ADT/VectorExtras.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Mon Feb 15 16:37:53 2010 @@ -25,7 +25,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/Target/TargetOptions.h" #include "llvm/ADT/VectorExtras.h" #include "llvm/Support/Debug.h" Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Mon Feb 15 16:37:53 2010 @@ -31,8 +31,8 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/SelectionDAGISel.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/ValueTypes.h" -#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" Modified: llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h (original) +++ llvm/trunk/lib/Target/Mips/MipsTargetObjectFile.h Mon Feb 15 16:37:53 2010 @@ -10,7 +10,7 @@ #ifndef LLVM_TARGET_MIPS_TARGETOBJECTFILE_H #define LLVM_TARGET_MIPS_TARGETOBJECTFILE_H -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" namespace llvm { Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Mon Feb 15 16:37:53 2010 @@ -31,13 +31,13 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Target/Mangler.h" -#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetOptions.h" Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Mon Feb 15 16:37:53 2010 @@ -25,13 +25,13 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Intrinsics.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Mon Feb 15 16:37:53 2010 @@ -21,7 +21,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/ADT/VectorExtras.h" #include "llvm/Support/ErrorHandling.h" using namespace llvm; Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Mon Feb 15 16:37:53 2010 @@ -30,9 +30,9 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/SelectionDAGISel.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Feb 15 16:37:53 2010 @@ -17,11 +17,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/GlobalVariable.h" -#include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCSectionMachO.h" -#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Target/Mangler.h" #include "llvm/Target/TargetData.h" @@ -31,7 +28,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -342,841 +338,3 @@ return dwarf::DW_EH_PE_absptr; } -//===----------------------------------------------------------------------===// -// ELF -//===----------------------------------------------------------------------===// -typedef StringMap ELFUniqueMapTy; - -TargetLoweringObjectFileELF::~TargetLoweringObjectFileELF() { - // If we have the section uniquing map, free it. - delete (ELFUniqueMapTy*)UniquingMap; -} - -const MCSection *TargetLoweringObjectFileELF:: -getELFSection(StringRef Section, unsigned Type, unsigned Flags, - SectionKind Kind, bool IsExplicit) const { - if (UniquingMap == 0) - UniquingMap = new ELFUniqueMapTy(); - ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)UniquingMap; - - // Do the lookup, if we have a hit, return it. - const MCSectionELF *&Entry = Map[Section]; - if (Entry) return Entry; - - return Entry = MCSectionELF::Create(Section, Type, Flags, Kind, IsExplicit, - getContext()); -} - -void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, - const TargetMachine &TM) { - if (UniquingMap != 0) - ((ELFUniqueMapTy*)UniquingMap)->clear(); - TargetLoweringObjectFile::Initialize(Ctx, TM); - - BSSSection = - getELFSection(".bss", MCSectionELF::SHT_NOBITS, - MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, - SectionKind::getBSS()); - - TextSection = - getELFSection(".text", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_EXECINSTR | MCSectionELF::SHF_ALLOC, - SectionKind::getText()); - - DataSection = - getELFSection(".data", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, - SectionKind::getDataRel()); - - ReadOnlySection = - getELFSection(".rodata", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC, - SectionKind::getReadOnly()); - - TLSDataSection = - getELFSection(".tdata", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_TLS | - MCSectionELF::SHF_WRITE, SectionKind::getThreadData()); - - TLSBSSSection = - getELFSection(".tbss", MCSectionELF::SHT_NOBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_TLS | - MCSectionELF::SHF_WRITE, SectionKind::getThreadBSS()); - - DataRelSection = - getELFSection(".data.rel", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, - SectionKind::getDataRel()); - - DataRelLocalSection = - getELFSection(".data.rel.local", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, - SectionKind::getDataRelLocal()); - - DataRelROSection = - getELFSection(".data.rel.ro", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, - SectionKind::getReadOnlyWithRel()); - - DataRelROLocalSection = - getELFSection(".data.rel.ro.local", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, - SectionKind::getReadOnlyWithRelLocal()); - - MergeableConst4Section = - getELFSection(".rodata.cst4", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE, - SectionKind::getMergeableConst4()); - - MergeableConst8Section = - getELFSection(".rodata.cst8", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE, - SectionKind::getMergeableConst8()); - - MergeableConst16Section = - getELFSection(".rodata.cst16", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_MERGE, - SectionKind::getMergeableConst16()); - - StaticCtorSection = - getELFSection(".ctors", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, - SectionKind::getDataRel()); - - StaticDtorSection = - getELFSection(".dtors", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, - SectionKind::getDataRel()); - - // Exception Handling Sections. - - // FIXME: We're emitting LSDA info into a readonly section on ELF, even though - // it contains relocatable pointers. In PIC mode, this is probably a big - // runtime hit for C++ apps. Either the contents of the LSDA need to be - // adjusted or this should be a data section. - LSDASection = - getELFSection(".gcc_except_table", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC, SectionKind::getReadOnly()); - EHFrameSection = - getELFSection(".eh_frame", MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | MCSectionELF::SHF_WRITE, - SectionKind::getDataRel()); - - // Debug Info Sections. - DwarfAbbrevSection = - getELFSection(".debug_abbrev", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfInfoSection = - getELFSection(".debug_info", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfLineSection = - getELFSection(".debug_line", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfFrameSection = - getELFSection(".debug_frame", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfPubNamesSection = - getELFSection(".debug_pubnames", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfPubTypesSection = - getELFSection(".debug_pubtypes", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfStrSection = - getELFSection(".debug_str", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfLocSection = - getELFSection(".debug_loc", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfARangesSection = - getELFSection(".debug_aranges", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfRangesSection = - getELFSection(".debug_ranges", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); - DwarfMacroInfoSection = - getELFSection(".debug_macinfo", MCSectionELF::SHT_PROGBITS, 0, - SectionKind::getMetadata()); -} - - -static SectionKind -getELFKindForNamedSection(StringRef Name, SectionKind K) { - if (Name.empty() || Name[0] != '.') return K; - - // Some lame default implementation based on some magic section names. - if (Name == ".bss" || - Name.startswith(".bss.") || - Name.startswith(".gnu.linkonce.b.") || - Name.startswith(".llvm.linkonce.b.") || - Name == ".sbss" || - Name.startswith(".sbss.") || - Name.startswith(".gnu.linkonce.sb.") || - Name.startswith(".llvm.linkonce.sb.")) - return SectionKind::getBSS(); - - if (Name == ".tdata" || - Name.startswith(".tdata.") || - Name.startswith(".gnu.linkonce.td.") || - Name.startswith(".llvm.linkonce.td.")) - return SectionKind::getThreadData(); - - if (Name == ".tbss" || - Name.startswith(".tbss.") || - Name.startswith(".gnu.linkonce.tb.") || - Name.startswith(".llvm.linkonce.tb.")) - return SectionKind::getThreadBSS(); - - return K; -} - - -static unsigned getELFSectionType(StringRef Name, SectionKind K) { - - if (Name == ".init_array") - return MCSectionELF::SHT_INIT_ARRAY; - - if (Name == ".fini_array") - return MCSectionELF::SHT_FINI_ARRAY; - - if (Name == ".preinit_array") - return MCSectionELF::SHT_PREINIT_ARRAY; - - if (K.isBSS() || K.isThreadBSS()) - return MCSectionELF::SHT_NOBITS; - - return MCSectionELF::SHT_PROGBITS; -} - - -static unsigned -getELFSectionFlags(SectionKind K) { - unsigned Flags = 0; - - if (!K.isMetadata()) - Flags |= MCSectionELF::SHF_ALLOC; - - if (K.isText()) - Flags |= MCSectionELF::SHF_EXECINSTR; - - if (K.isWriteable()) - Flags |= MCSectionELF::SHF_WRITE; - - if (K.isThreadLocal()) - Flags |= MCSectionELF::SHF_TLS; - - // K.isMergeableConst() is left out to honour PR4650 - if (K.isMergeableCString() || K.isMergeableConst4() || - K.isMergeableConst8() || K.isMergeableConst16()) - Flags |= MCSectionELF::SHF_MERGE; - - if (K.isMergeableCString()) - Flags |= MCSectionELF::SHF_STRINGS; - - return Flags; -} - - -const MCSection *TargetLoweringObjectFileELF:: -getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const { - StringRef SectionName = GV->getSection(); - - // Infer section flags from the section name if we can. - Kind = getELFKindForNamedSection(SectionName, Kind); - - return getELFSection(SectionName, - getELFSectionType(SectionName, Kind), - getELFSectionFlags(Kind), Kind, true); -} - -static const char *getSectionPrefixForUniqueGlobal(SectionKind Kind) { - if (Kind.isText()) return ".gnu.linkonce.t."; - if (Kind.isReadOnly()) return ".gnu.linkonce.r."; - - if (Kind.isThreadData()) return ".gnu.linkonce.td."; - if (Kind.isThreadBSS()) return ".gnu.linkonce.tb."; - - if (Kind.isDataNoRel()) return ".gnu.linkonce.d."; - if (Kind.isDataRelLocal()) return ".gnu.linkonce.d.rel.local."; - if (Kind.isDataRel()) return ".gnu.linkonce.d.rel."; - if (Kind.isReadOnlyWithRelLocal()) return ".gnu.linkonce.d.rel.ro.local."; - - assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); - return ".gnu.linkonce.d.rel.ro."; -} - -const MCSection *TargetLoweringObjectFileELF:: -SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const { - - // If this global is linkonce/weak and the target handles this by emitting it - // into a 'uniqued' section name, create and return the section now. - if (GV->isWeakForLinker() && !Kind.isCommon() && !Kind.isBSS()) { - const char *Prefix = getSectionPrefixForUniqueGlobal(Kind); - SmallString<128> Name; - Name.append(Prefix, Prefix+strlen(Prefix)); - Mang->getNameWithPrefix(Name, GV, false); - return getELFSection(Name.str(), getELFSectionType(Name.str(), Kind), - getELFSectionFlags(Kind), Kind); - } - - if (Kind.isText()) return TextSection; - - if (Kind.isMergeable1ByteCString() || - Kind.isMergeable2ByteCString() || - Kind.isMergeable4ByteCString()) { - - // We also need alignment here. - // FIXME: this is getting the alignment of the character, not the - // alignment of the global! - unsigned Align = - TM.getTargetData()->getPreferredAlignment(cast(GV)); - - const char *SizeSpec = ".rodata.str1."; - if (Kind.isMergeable2ByteCString()) - SizeSpec = ".rodata.str2."; - else if (Kind.isMergeable4ByteCString()) - SizeSpec = ".rodata.str4."; - else - assert(Kind.isMergeable1ByteCString() && "unknown string width"); - - - std::string Name = SizeSpec + utostr(Align); - return getELFSection(Name, MCSectionELF::SHT_PROGBITS, - MCSectionELF::SHF_ALLOC | - MCSectionELF::SHF_MERGE | - MCSectionELF::SHF_STRINGS, - Kind); - } - - if (Kind.isMergeableConst()) { - if (Kind.isMergeableConst4() && MergeableConst4Section) - return MergeableConst4Section; - if (Kind.isMergeableConst8() && MergeableConst8Section) - return MergeableConst8Section; - if (Kind.isMergeableConst16() && MergeableConst16Section) - return MergeableConst16Section; - return ReadOnlySection; // .const - } - - if (Kind.isReadOnly()) return ReadOnlySection; - - if (Kind.isThreadData()) return TLSDataSection; - if (Kind.isThreadBSS()) return TLSBSSSection; - - // Note: we claim that common symbols are put in BSSSection, but they are - // really emitted with the magic .comm directive, which creates a symbol table - // entry but not a section. - if (Kind.isBSS() || Kind.isCommon()) return BSSSection; - - if (Kind.isDataNoRel()) return DataSection; - if (Kind.isDataRelLocal()) return DataRelLocalSection; - if (Kind.isDataRel()) return DataRelSection; - if (Kind.isReadOnlyWithRelLocal()) return DataRelROLocalSection; - - assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); - return DataRelROSection; -} - -/// getSectionForConstant - Given a mergeable constant with the -/// specified size and relocation information, return a section that it -/// should be placed in. -const MCSection *TargetLoweringObjectFileELF:: -getSectionForConstant(SectionKind Kind) const { - if (Kind.isMergeableConst4() && MergeableConst4Section) - return MergeableConst4Section; - if (Kind.isMergeableConst8() && MergeableConst8Section) - return MergeableConst8Section; - if (Kind.isMergeableConst16() && MergeableConst16Section) - return MergeableConst16Section; - if (Kind.isReadOnly()) - return ReadOnlySection; - - if (Kind.isReadOnlyWithRelLocal()) return DataRelROLocalSection; - assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); - return DataRelROSection; -} - -const MCExpr *TargetLoweringObjectFileELF:: -getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, unsigned Encoding) const { - - if (Encoding & dwarf::DW_EH_PE_indirect) { - MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo(); - - SmallString<128> Name; - Mang->getNameWithPrefix(Name, GV, true); - Name += ".DW.stub"; - - // Add information about the stub reference to ELFMMI so that the stub - // gets emitted by the asmprinter. - MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); - MCSymbol *&StubSym = ELFMMI.getGVStubEntry(Sym); - if (StubSym == 0) { - Name.clear(); - Mang->getNameWithPrefix(Name, GV, false); - StubSym = getContext().GetOrCreateSymbol(Name.str()); - } - - return TargetLoweringObjectFile:: - getSymbolForDwarfReference(Sym, MMI, - Encoding & ~dwarf::DW_EH_PE_indirect); - } - - return TargetLoweringObjectFile:: - getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding); -} - -//===----------------------------------------------------------------------===// -// MachO -//===----------------------------------------------------------------------===// - -typedef StringMap MachOUniqueMapTy; - -TargetLoweringObjectFileMachO::~TargetLoweringObjectFileMachO() { - // If we have the MachO uniquing map, free it. - delete (MachOUniqueMapTy*)UniquingMap; -} - - -const MCSectionMachO *TargetLoweringObjectFileMachO:: -getMachOSection(StringRef Segment, StringRef Section, - unsigned TypeAndAttributes, - unsigned Reserved2, SectionKind Kind) const { - // We unique sections by their segment/section pair. The returned section - // may not have the same flags as the requested section, if so this should be - // diagnosed by the client as an error. - - // Create the map if it doesn't already exist. - if (UniquingMap == 0) - UniquingMap = new MachOUniqueMapTy(); - MachOUniqueMapTy &Map = *(MachOUniqueMapTy*)UniquingMap; - - // Form the name to look up. - SmallString<64> Name; - Name += Segment; - Name.push_back(','); - Name += Section; - - // Do the lookup, if we have a hit, return it. - const MCSectionMachO *&Entry = Map[Name.str()]; - if (Entry) return Entry; - - // Otherwise, return a new section. - return Entry = MCSectionMachO::Create(Segment, Section, TypeAndAttributes, - Reserved2, Kind, getContext()); -} - - -void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx, - const TargetMachine &TM) { - if (UniquingMap != 0) - ((MachOUniqueMapTy*)UniquingMap)->clear(); - TargetLoweringObjectFile::Initialize(Ctx, TM); - - TextSection // .text - = getMachOSection("__TEXT", "__text", - MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, - SectionKind::getText()); - DataSection // .data - = getMachOSection("__DATA", "__data", 0, SectionKind::getDataRel()); - - CStringSection // .cstring - = getMachOSection("__TEXT", "__cstring", MCSectionMachO::S_CSTRING_LITERALS, - SectionKind::getMergeable1ByteCString()); - UStringSection - = getMachOSection("__TEXT","__ustring", 0, - SectionKind::getMergeable2ByteCString()); - FourByteConstantSection // .literal4 - = getMachOSection("__TEXT", "__literal4", MCSectionMachO::S_4BYTE_LITERALS, - SectionKind::getMergeableConst4()); - EightByteConstantSection // .literal8 - = getMachOSection("__TEXT", "__literal8", MCSectionMachO::S_8BYTE_LITERALS, - SectionKind::getMergeableConst8()); - - // ld_classic doesn't support .literal16 in 32-bit mode, and ld64 falls back - // to using it in -static mode. - SixteenByteConstantSection = 0; - if (TM.getRelocationModel() != Reloc::Static && - TM.getTargetData()->getPointerSize() == 32) - SixteenByteConstantSection = // .literal16 - getMachOSection("__TEXT", "__literal16",MCSectionMachO::S_16BYTE_LITERALS, - SectionKind::getMergeableConst16()); - - ReadOnlySection // .const - = getMachOSection("__TEXT", "__const", 0, SectionKind::getReadOnly()); - - TextCoalSection - = getMachOSection("__TEXT", "__textcoal_nt", - MCSectionMachO::S_COALESCED | - MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, - SectionKind::getText()); - ConstTextCoalSection - = getMachOSection("__TEXT", "__const_coal", MCSectionMachO::S_COALESCED, - SectionKind::getText()); - ConstDataCoalSection - = getMachOSection("__DATA","__const_coal", MCSectionMachO::S_COALESCED, - SectionKind::getText()); - ConstDataSection // .const_data - = getMachOSection("__DATA", "__const", 0, - SectionKind::getReadOnlyWithRel()); - DataCoalSection - = getMachOSection("__DATA","__datacoal_nt", MCSectionMachO::S_COALESCED, - SectionKind::getDataRel()); - DataCommonSection - = getMachOSection("__DATA","__common", MCSectionMachO::S_ZEROFILL, - SectionKind::getBSS()); - DataBSSSection - = getMachOSection("__DATA","__bss", MCSectionMachO::S_ZEROFILL, - SectionKind::getBSS()); - - - LazySymbolPointerSection - = getMachOSection("__DATA", "__la_symbol_ptr", - MCSectionMachO::S_LAZY_SYMBOL_POINTERS, - SectionKind::getMetadata()); - NonLazySymbolPointerSection - = getMachOSection("__DATA", "__nl_symbol_ptr", - MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS, - SectionKind::getMetadata()); - - if (TM.getRelocationModel() == Reloc::Static) { - StaticCtorSection - = getMachOSection("__TEXT", "__constructor", 0,SectionKind::getDataRel()); - StaticDtorSection - = getMachOSection("__TEXT", "__destructor", 0, SectionKind::getDataRel()); - } else { - StaticCtorSection - = getMachOSection("__DATA", "__mod_init_func", - MCSectionMachO::S_MOD_INIT_FUNC_POINTERS, - SectionKind::getDataRel()); - StaticDtorSection - = getMachOSection("__DATA", "__mod_term_func", - MCSectionMachO::S_MOD_TERM_FUNC_POINTERS, - SectionKind::getDataRel()); - } - - // Exception Handling. - LSDASection = getMachOSection("__DATA", "__gcc_except_tab", 0, - SectionKind::getDataRel()); - EHFrameSection = - getMachOSection("__TEXT", "__eh_frame", - MCSectionMachO::S_COALESCED | - MCSectionMachO::S_ATTR_NO_TOC | - MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS | - MCSectionMachO::S_ATTR_LIVE_SUPPORT, - SectionKind::getReadOnly()); - - // Debug Information. - DwarfAbbrevSection = - getMachOSection("__DWARF", "__debug_abbrev", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfInfoSection = - getMachOSection("__DWARF", "__debug_info", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfLineSection = - getMachOSection("__DWARF", "__debug_line", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfFrameSection = - getMachOSection("__DWARF", "__debug_frame", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfPubNamesSection = - getMachOSection("__DWARF", "__debug_pubnames", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfPubTypesSection = - getMachOSection("__DWARF", "__debug_pubtypes", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfStrSection = - getMachOSection("__DWARF", "__debug_str", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfLocSection = - getMachOSection("__DWARF", "__debug_loc", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfARangesSection = - getMachOSection("__DWARF", "__debug_aranges", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfRangesSection = - getMachOSection("__DWARF", "__debug_ranges", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfMacroInfoSection = - getMachOSection("__DWARF", "__debug_macinfo", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); - DwarfDebugInlineSection = - getMachOSection("__DWARF", "__debug_inlined", MCSectionMachO::S_ATTR_DEBUG, - SectionKind::getMetadata()); -} - -const MCSection *TargetLoweringObjectFileMachO:: -getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const { - // Parse the section specifier and create it if valid. - StringRef Segment, Section; - unsigned TAA, StubSize; - std::string ErrorCode = - MCSectionMachO::ParseSectionSpecifier(GV->getSection(), Segment, Section, - TAA, StubSize); - if (!ErrorCode.empty()) { - // If invalid, report the error with llvm_report_error. - llvm_report_error("Global variable '" + GV->getNameStr() + - "' has an invalid section specifier '" + GV->getSection()+ - "': " + ErrorCode + "."); - // Fall back to dropping it into the data section. - return DataSection; - } - - // Get the section. - const MCSectionMachO *S = - getMachOSection(Segment, Section, TAA, StubSize, Kind); - - // Okay, now that we got the section, verify that the TAA & StubSize agree. - // If the user declared multiple globals with different section flags, we need - // to reject it here. - if (S->getTypeAndAttributes() != TAA || S->getStubSize() != StubSize) { - // If invalid, report the error with llvm_report_error. - llvm_report_error("Global variable '" + GV->getNameStr() + - "' section type or attributes does not match previous" - " section specifier"); - } - - return S; -} - -const MCSection *TargetLoweringObjectFileMachO:: -SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const { - assert(!Kind.isThreadLocal() && "Darwin doesn't support TLS"); - - if (Kind.isText()) - return GV->isWeakForLinker() ? TextCoalSection : TextSection; - - // If this is weak/linkonce, put this in a coalescable section, either in text - // or data depending on if it is writable. - if (GV->isWeakForLinker()) { - if (Kind.isReadOnly()) - return ConstTextCoalSection; - return DataCoalSection; - } - - // FIXME: Alignment check should be handled by section classifier. - if (Kind.isMergeable1ByteCString() || - Kind.isMergeable2ByteCString()) { - if (TM.getTargetData()->getPreferredAlignment( - cast(GV)) < 32) { - if (Kind.isMergeable1ByteCString()) - return CStringSection; - assert(Kind.isMergeable2ByteCString()); - return UStringSection; - } - } - - if (Kind.isMergeableConst()) { - if (Kind.isMergeableConst4()) - return FourByteConstantSection; - if (Kind.isMergeableConst8()) - return EightByteConstantSection; - if (Kind.isMergeableConst16() && SixteenByteConstantSection) - return SixteenByteConstantSection; - } - - // Otherwise, if it is readonly, but not something we can specially optimize, - // just drop it in .const. - if (Kind.isReadOnly()) - return ReadOnlySection; - - // If this is marked const, put it into a const section. But if the dynamic - // linker needs to write to it, put it in the data segment. - if (Kind.isReadOnlyWithRel()) - return ConstDataSection; - - // Put zero initialized globals with strong external linkage in the - // DATA, __common section with the .zerofill directive. - if (Kind.isBSSExtern()) - return DataCommonSection; - - // Put zero initialized globals with local linkage in __DATA,__bss directive - // with the .zerofill directive (aka .lcomm). - if (Kind.isBSSLocal()) - return DataBSSSection; - - // Otherwise, just drop the variable in the normal data section. - return DataSection; -} - -const MCSection * -TargetLoweringObjectFileMachO::getSectionForConstant(SectionKind Kind) const { - // If this constant requires a relocation, we have to put it in the data - // segment, not in the text segment. - if (Kind.isDataRel() || Kind.isReadOnlyWithRel()) - return ConstDataSection; - - if (Kind.isMergeableConst4()) - return FourByteConstantSection; - if (Kind.isMergeableConst8()) - return EightByteConstantSection; - if (Kind.isMergeableConst16() && SixteenByteConstantSection) - return SixteenByteConstantSection; - return ReadOnlySection; // .const -} - -/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively decide -/// not to emit the UsedDirective for some symbols in llvm.used. -// FIXME: REMOVE this (rdar://7071300) -bool TargetLoweringObjectFileMachO:: -shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const { - /// On Darwin, internally linked data beginning with "L" or "l" does not have - /// the directive emitted (this occurs in ObjC metadata). - if (!GV) return false; - - // Check whether the mangled name has the "Private" or "LinkerPrivate" prefix. - if (GV->hasLocalLinkage() && !isa(GV)) { - // FIXME: ObjC metadata is currently emitted as internal symbols that have - // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and - // this horrible hack can go away. - SmallString<64> Name; - Mang->getNameWithPrefix(Name, GV, false); - if (Name[0] == 'L' || Name[0] == 'l') - return false; - } - - return true; -} - -const MCExpr *TargetLoweringObjectFileMachO:: -getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, unsigned Encoding) const { - // The mach-o version of this method defaults to returning a stub reference. - - if (Encoding & dwarf::DW_EH_PE_indirect) { - SmallString<128> Name; - Mang->getNameWithPrefix(Name, GV, true); - Name += "$non_lazy_ptr"; - MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str()); - - return TargetLoweringObjectFile:: - getSymbolForDwarfReference(Sym, MMI, - Encoding & ~dwarf::DW_EH_PE_indirect); - } - - return TargetLoweringObjectFile:: - getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding); -} - - -//===----------------------------------------------------------------------===// -// COFF -//===----------------------------------------------------------------------===// - -typedef StringMap COFFUniqueMapTy; - -TargetLoweringObjectFileCOFF::~TargetLoweringObjectFileCOFF() { - delete (COFFUniqueMapTy*)UniquingMap; -} - - -const MCSection *TargetLoweringObjectFileCOFF:: -getCOFFSection(StringRef Name, bool isDirective, SectionKind Kind) const { - // Create the map if it doesn't already exist. - if (UniquingMap == 0) - UniquingMap = new MachOUniqueMapTy(); - COFFUniqueMapTy &Map = *(COFFUniqueMapTy*)UniquingMap; - - // Do the lookup, if we have a hit, return it. - const MCSectionCOFF *&Entry = Map[Name]; - if (Entry) return Entry; - - return Entry = MCSectionCOFF::Create(Name, isDirective, Kind, getContext()); -} - -void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx, - const TargetMachine &TM) { - if (UniquingMap != 0) - ((COFFUniqueMapTy*)UniquingMap)->clear(); - TargetLoweringObjectFile::Initialize(Ctx, TM); - TextSection = getCOFFSection("\t.text", true, SectionKind::getText()); - DataSection = getCOFFSection("\t.data", true, SectionKind::getDataRel()); - StaticCtorSection = - getCOFFSection(".ctors", false, SectionKind::getDataRel()); - StaticDtorSection = - getCOFFSection(".dtors", false, SectionKind::getDataRel()); - - // FIXME: We're emitting LSDA info into a readonly section on COFF, even - // though it contains relocatable pointers. In PIC mode, this is probably a - // big runtime hit for C++ apps. Either the contents of the LSDA need to be - // adjusted or this should be a data section. - LSDASection = - getCOFFSection(".gcc_except_table", false, SectionKind::getReadOnly()); - EHFrameSection = - getCOFFSection(".eh_frame", false, SectionKind::getDataRel()); - - // Debug info. - // FIXME: Don't use 'directive' mode here. - DwarfAbbrevSection = - getCOFFSection("\t.section\t.debug_abbrev,\"dr\"", - true, SectionKind::getMetadata()); - DwarfInfoSection = - getCOFFSection("\t.section\t.debug_info,\"dr\"", - true, SectionKind::getMetadata()); - DwarfLineSection = - getCOFFSection("\t.section\t.debug_line,\"dr\"", - true, SectionKind::getMetadata()); - DwarfFrameSection = - getCOFFSection("\t.section\t.debug_frame,\"dr\"", - true, SectionKind::getMetadata()); - DwarfPubNamesSection = - getCOFFSection("\t.section\t.debug_pubnames,\"dr\"", - true, SectionKind::getMetadata()); - DwarfPubTypesSection = - getCOFFSection("\t.section\t.debug_pubtypes,\"dr\"", - true, SectionKind::getMetadata()); - DwarfStrSection = - getCOFFSection("\t.section\t.debug_str,\"dr\"", - true, SectionKind::getMetadata()); - DwarfLocSection = - getCOFFSection("\t.section\t.debug_loc,\"dr\"", - true, SectionKind::getMetadata()); - DwarfARangesSection = - getCOFFSection("\t.section\t.debug_aranges,\"dr\"", - true, SectionKind::getMetadata()); - DwarfRangesSection = - getCOFFSection("\t.section\t.debug_ranges,\"dr\"", - true, SectionKind::getMetadata()); - DwarfMacroInfoSection = - getCOFFSection("\t.section\t.debug_macinfo,\"dr\"", - true, SectionKind::getMetadata()); -} - -const MCSection *TargetLoweringObjectFileCOFF:: -getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const { - return getCOFFSection(GV->getSection(), false, Kind); -} - -static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) { - if (Kind.isText()) - return ".text$linkonce"; - if (Kind.isWriteable()) - return ".data$linkonce"; - return ".rdata$linkonce"; -} - - -const MCSection *TargetLoweringObjectFileCOFF:: -SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler *Mang, const TargetMachine &TM) const { - assert(!Kind.isThreadLocal() && "Doesn't support TLS"); - - // If this global is linkonce/weak and the target handles this by emitting it - // into a 'uniqued' section name, create and return the section now. - if (GV->isWeakForLinker()) { - const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind); - SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); - Mang->getNameWithPrefix(Name, GV, false); - return getCOFFSection(Name.str(), false, Kind); - } - - if (Kind.isText()) - return getTextSection(); - - return getDataSection(); -} - Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Mon Feb 15 16:37:53 2010 @@ -33,11 +33,11 @@ #include "llvm/MC/MCSymbol.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/Target/Mangler.h" -#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/ADT/SmallString.h" Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Mon Feb 15 16:37:53 2010 @@ -10,6 +10,7 @@ #ifndef LLVM_TARGET_X86_TARGETOBJECTFILE_H #define LLVM_TARGET_X86_TARGETOBJECTFILE_H +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetLoweringObjectFile.h" Modified: llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h?rev=96288&r1=96287&r2=96288&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h (original) +++ llvm/trunk/lib/Target/XCore/XCoreTargetObjectFile.h Mon Feb 15 16:37:53 2010 @@ -10,13 +10,12 @@ #ifndef LLVM_TARGET_XCORE_TARGETOBJECTFILE_H #define LLVM_TARGET_XCORE_TARGETOBJECTFILE_H -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" namespace llvm { class XCoreTargetObjectFile : public TargetLoweringObjectFileELF { public: - void Initialize(MCContext &Ctx, const TargetMachine &TM); // TODO: Classify globals as xcore wishes. From asl at math.spbu.ru Mon Feb 15 16:38:25 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Feb 2010 22:38:25 -0000 Subject: [llvm-commits] [llvm] r96290 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Message-ID: <201002152238.o1FMcPwY024495@zion.cs.uiuc.edu> Author: asl Date: Mon Feb 15 16:38:25 2010 New Revision: 96290 URL: http://llvm.org/viewvc/llvm-project?rev=96290&view=rev Log: Use ttype encoding consistently Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=96290&r1=96289&r2=96290&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Mon Feb 15 16:38:25 2010 @@ -870,7 +870,7 @@ EmitReference(GV, TTypeEncoding); EOL("TypeInfo"); } else { - PrintRelDirective(); + PrintRelDirective(TTypeEncoding); O << "0x0"; EOL(""); } From asl at math.spbu.ru Mon Feb 15 16:38:10 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Feb 2010 22:38:10 -0000 Subject: [llvm-commits] [llvm] r96289 - /llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Message-ID: <201002152238.o1FMcAbq024471@zion.cs.uiuc.edu> Author: asl Date: Mon Feb 15 16:38:10 2010 New Revision: 96289 URL: http://llvm.org/viewvc/llvm-project?rev=96289&view=rev Log: Fix a silly darwin-only typo introduced during merge. Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=96289&r1=96288&r2=96289&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Mon Feb 15 16:38:10 2010 @@ -56,15 +56,14 @@ // On Darwin/X86-64, we can reference dwarf symbols with foo at GOTPCREL+4, which // is an indirect pc-relative reference. - if ((Encoding & DW_EH_PE_indirect) && - (Encoding & DW_EH_PE_pcrel)) { + if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) { SmallString<128> Name; Mang->getNameWithPrefix(Name, GV, false); - const MCSymbol *Sym = getContext().CreateSymbol(Name); - const MCExpr *Res = - X86MCTargetExpr::Create(Sym, X86MCTargetExpr::GOTPCREL, getContext()); - const MCExpr *Four = MCConstantExpr::Create(4, getContext()); - return MCBinaryExpr::CreateAdd(Res, Four, getContext()); + const MCSymbol *Sym = getContext().GetOrCreateSymbol(Name); + const MCExpr *Res = + X86MCTargetExpr::Create(Sym, X86MCTargetExpr::GOTPCREL, getContext()); + const MCExpr *Four = MCConstantExpr::Create(4, getContext()); + return MCBinaryExpr::CreateAdd(Res, Four, getContext()); } return TargetLoweringObjectFileMachO:: From nicolas.geoffray at gmail.com Mon Feb 15 16:44:58 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Mon, 15 Feb 2010 23:44:58 +0100 Subject: [llvm-commits] [PATCH] Fix memory leak in SelectionDAG.cpp Message-ID: Dear all, The following patch fixes a memory leak found by valgrind in SelectionDAG.cpp. I am not familiar with the codegen system, so please someone comment & apply. Thanks! Nicolas -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/fabf1666/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: leak.patch Type: application/octet-stream Size: 408 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/fabf1666/attachment.obj From evan.cheng at apple.com Mon Feb 15 16:51:10 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Feb 2010 14:51:10 -0800 Subject: [llvm-commits] [PATCH] Fix memory leak in SelectionDAG.cpp In-Reply-To: References: Message-ID: <8A5E7236-ABBC-4DBB-9039-2BB845A61C64@apple.com> Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp (revision 96248) +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp (working copy) @@ -829,6 +829,7 @@ EntryNode.UseList = 0; AllNodes.push_back(&EntryNode); Root = getEntryNode(); + delete Ordering; Ordering = new SDNodeOrdering(); } Thanks. But this is somewhat surprising. SelectionDAG::~SelectionDAG() does destroy Ordering. I don't understand under what condition this would leak memory? Evan On Feb 15, 2010, at 2:44 PM, nicolas geoffray wrote: > Dear all, > > The following patch fixes a memory leak found by valgrind in SelectionDAG.cpp. I am not familiar with the codegen system, so please someone comment & apply. > > Thanks! > Nicolas > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicolas.geoffray at gmail.com Mon Feb 15 16:54:24 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Mon, 15 Feb 2010 23:54:24 +0100 Subject: [llvm-commits] [PATCH] Fix memory leak in SelectionDAG.cpp In-Reply-To: <8A5E7236-ABBC-4DBB-9039-2BB845A61C64@apple.com> References: <8A5E7236-ABBC-4DBB-9039-2BB845A61C64@apple.com> Message-ID: Yes, SelectionDAG::~SelectionDAG() does destroy Ordering, but here it's not about the destructor, it's about the clear method, which allocates a new ordering for the DAG without destroying the previous one. Nicolas On Mon, Feb 15, 2010 at 11:51 PM, Evan Cheng wrote: > Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp > =================================================================== > --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp (revision 96248) > +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp (working copy) > @@ -829,6 +829,7 @@ > EntryNode.UseList = 0; > AllNodes.push_back(&EntryNode); > Root = getEntryNode(); > + delete Ordering; > Ordering = new SDNodeOrdering(); > } > > Thanks. But this is somewhat surprising. SelectionDAG::~SelectionDAG() > does destroy Ordering. I don't understand under what condition this would > leak memory? > > Evan > > On Feb 15, 2010, at 2:44 PM, nicolas geoffray wrote: > > > Dear all, > > > > The following patch fixes a memory leak found by valgrind in > SelectionDAG.cpp. I am not familiar with the codegen system, so please > someone comment & apply. > > > > Thanks! > > Nicolas > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/46018593/attachment.html From asl at math.spbu.ru Mon Feb 15 16:55:18 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Feb 2010 22:55:18 -0000 Subject: [llvm-commits] [llvm] r96292 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <201002152255.o1FMtJpP025561@zion.cs.uiuc.edu> Author: asl Date: Mon Feb 15 16:55:13 2010 New Revision: 96292 URL: http://llvm.org/viewvc/llvm-project?rev=96292&view=rev Log: Add missed entry to cmake build list file Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=96292&r1=96291&r2=96292&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Mon Feb 15 16:55:13 2010 @@ -67,6 +67,7 @@ StrongPHIElimination.cpp TailDuplication.cpp TargetInstrInfoImpl.cpp + TargetLoweringObjectFileImpl.cpp TwoAddressInstructionPass.cpp UnreachableBlockElim.cpp VirtRegMap.cpp From dalej at apple.com Mon Feb 15 17:05:03 2010 From: dalej at apple.com (Dale Johannesen) Date: Mon, 15 Feb 2010 23:05:03 -0000 Subject: [llvm-commits] [llvm] r96294 - /llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Message-ID: <201002152305.o1FN53JQ026014@zion.cs.uiuc.edu> Author: johannes Date: Mon Feb 15 17:05:03 2010 New Revision: 96294 URL: http://llvm.org/viewvc/llvm-project?rev=96294&view=rev Log: More handling of DBG_VALUE. Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=96294&r1=96293&r2=96294&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Mon Feb 15 17:05:03 2010 @@ -490,10 +490,12 @@ // If the virtual register is already available, just update the instruction // and return. if (unsigned PR = getVirt2PhysRegMapSlot(VirtReg)) { - MarkPhysRegRecentlyUsed(PR); // Already have this value available! MI->getOperand(OpNum).setReg(PR); // Assign the input register - if (!MI->isDebugValue()) + if (!MI->isDebugValue()) { + // Do not do these for DBG_VALUE as they can affect codegen. + MarkPhysRegRecentlyUsed(PR); // Already have this value available! getVirtRegLastUse(VirtReg) = std::make_pair(MI, OpNum); + } return MI; } @@ -694,7 +696,13 @@ bool usedOutsideBlock = isPhysReg ? false : UsedInMultipleBlocks.test(MO.getReg() - TargetRegisterInfo::FirstVirtualRegister); - if (!isPhysReg && !usedOutsideBlock) + if (!isPhysReg && !usedOutsideBlock) { + // DBG_VALUE complicates this: if the only refs of a register outside + // this block are DBG_VALUE, we can't keep the reg live just for that, + // as it will cause the reg to be spilled at the end of this block when + // it wouldn't have been otherwise. Nullify the DBG_VALUEs when that + // happens. + bool UsedByDebugValueOnly = false; for (MachineRegisterInfo::reg_iterator UI = MRI.reg_begin(MO.getReg()), UE = MRI.reg_end(); UI != UE; ++UI) // Two cases: @@ -702,12 +710,26 @@ // - used in the same block before it is defined (loop) if (UI->getParent() != &MBB || (MO.isDef() && UI.getOperand().isUse() && precedes(&*UI, MI))) { + if (UI->isDebugValue()) { + UsedByDebugValueOnly = true; + continue; + } + // A non-DBG_VALUE use means we can leave DBG_VALUE uses alone. UsedInMultipleBlocks.set(MO.getReg() - TargetRegisterInfo::FirstVirtualRegister); usedOutsideBlock = true; + UsedByDebugValueOnly = false; break; } - + if (UsedByDebugValueOnly) + for (MachineRegisterInfo::reg_iterator UI = MRI.reg_begin(MO.getReg()), + UE = MRI.reg_end(); UI != UE; ++UI) + if (UI->isDebugValue() && + (UI->getParent() != &MBB || + (MO.isDef() && precedes(&*UI, MI)))) + UI.getOperand().setReg(0U); + } + // Physical registers and those that are not live-out of the block // are killed/dead at their last use/def within this block. if (isPhysReg || !usedOutsideBlock) { From evan.cheng at apple.com Mon Feb 15 17:16:53 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Feb 2010 23:16:53 -0000 Subject: [llvm-commits] [llvm] r96295 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <201002152316.o1FNGsAT026637@zion.cs.uiuc.edu> Author: evancheng Date: Mon Feb 15 17:16:53 2010 New Revision: 96295 URL: http://llvm.org/viewvc/llvm-project?rev=96295&view=rev Log: Fix a memory leak. Patch by Nicolas Geoffray. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=96295&r1=96294&r2=96295&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Feb 15 17:16:53 2010 @@ -829,6 +829,7 @@ EntryNode.UseList = 0; AllNodes.push_back(&EntryNode); Root = getEntryNode(); + delete Ordering; Ordering = new SDNodeOrdering(); } From espindola at google.com Mon Feb 15 17:16:57 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 15 Feb 2010 18:16:57 -0500 Subject: [llvm-commits] [ppc linux] Drop support for the InReg attribute Message-ID: <38a0d8451002151516m4f65b6a6p1d4caaca28b2ef52@mail.gmail.com> The attached patch drops support for the InReg attribute in the ppc linux backend. It is no longer used by llvm-gcc. There were no tests for this feature, so make check-lit is clean. Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: inreg.patch Type: text/x-diff Size: 1934 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/07cacff6/attachment.bin From evan.cheng at apple.com Mon Feb 15 17:17:03 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Feb 2010 15:17:03 -0800 Subject: [llvm-commits] [PATCH] Fix memory leak in SelectionDAG.cpp In-Reply-To: References: <8A5E7236-ABBC-4DBB-9039-2BB845A61C64@apple.com> Message-ID: <8423CC1F-A16A-45AA-9EE7-979A06AF3B73@apple.com> Ah of course. I thought it's the ctor. This patch looks good, I've committed it. Thanks. Evan On Feb 15, 2010, at 2:54 PM, nicolas geoffray wrote: > Yes, SelectionDAG::~SelectionDAG() does destroy Ordering, but here it's not about the destructor, it's about the clear method, which allocates a new ordering for the DAG without destroying the previous one. > > Nicolas > > On Mon, Feb 15, 2010 at 11:51 PM, Evan Cheng wrote: > Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp > =================================================================== > --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp (revision 96248) > +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp (working copy) > @@ -829,6 +829,7 @@ > EntryNode.UseList = 0; > AllNodes.push_back(&EntryNode); > Root = getEntryNode(); > + delete Ordering; > Ordering = new SDNodeOrdering(); > } > > Thanks. But this is somewhat surprising. SelectionDAG::~SelectionDAG() does destroy Ordering. I don't understand under what condition this would leak memory? > > Evan > > On Feb 15, 2010, at 2:44 PM, nicolas geoffray wrote: > > > Dear all, > > > > The following patch fixes a memory leak found by valgrind in SelectionDAG.cpp. I am not familiar with the codegen system, so please someone comment & apply. > > > > Thanks! > > Nicolas > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/e0c8cf3f/attachment.html From bob.wilson at apple.com Mon Feb 15 17:43:47 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 15 Feb 2010 23:43:47 -0000 Subject: [llvm-commits] [llvm] r96297 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002152343.o1FNhl8W027844@zion.cs.uiuc.edu> Author: bwilson Date: Mon Feb 15 17:43:47 2010 New Revision: 96297 URL: http://llvm.org/viewvc/llvm-project?rev=96297&view=rev Log: Put repeated empty pattern into the AQI instruction class. We could almost use a multiclass for the signed/unsigned instructions, but there are only 6 of them so I guess it's not worth it. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96297&r1=96296&r2=96297&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Feb 15 17:43:47 2010 @@ -1361,60 +1361,30 @@ // Saturating adds/subtracts -- for disassembly only // GPR:$dst = GPR:$a op GPR:$b -class AQI op27_20, bits<4> op7_4, string opc, list pattern> +class AQI op27_20, bits<4> op7_4, string opc> : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, IIC_iALUr, - opc, "\t$dst, $a, $b", pattern> { + opc, "\t$dst, $a, $b", + [/* For disassembly only; pattern left blank */]> { let Inst{27-20} = op27_20; let Inst{7-4} = op7_4; } -def QADD : AQI<0b00010000, 0b0101, "qadd", - [/* For disassembly only; pattern left blank */]>; - -def QADD16 : AQI<0b01100010, 0b0001, "qadd16", - [/* For disassembly only; pattern left blank */]>; - -def QADD8 : AQI<0b01100010, 0b1001, "qadd8", - [/* For disassembly only; pattern left blank */]>; - -def QASX : AQI<0b01100010, 0b0011, "qasx", - [/* For disassembly only; pattern left blank */]>; - -def QDADD : AQI<0b00010100, 0b0101, "qdadd", - [/* For disassembly only; pattern left blank */]>; - -def QDSUB : AQI<0b00010110, 0b0101, "qdsub", - [/* For disassembly only; pattern left blank */]>; - -def QSAX : AQI<0b01100010, 0b0101, "qsax", - [/* For disassembly only; pattern left blank */]>; - -def QSUB : AQI<0b00010010, 0b0101, "qsub", - [/* For disassembly only; pattern left blank */]>; - -def QSUB16 : AQI<0b01100010, 0b0111, "qsub16", - [/* For disassembly only; pattern left blank */]>; - -def QSUB8 : AQI<0b01100010, 0b1111, "qsub8", - [/* For disassembly only; pattern left blank */]>; - -def UQADD16 : AQI<0b01100110, 0b0001, "uqadd16", - [/* For disassembly only; pattern left blank */]>; - -def UQADD8 : AQI<0b01100110, 0b1001, "uqadd8", - [/* For disassembly only; pattern left blank */]>; - -def UQASX : AQI<0b01100110, 0b0011, "uqasx", - [/* For disassembly only; pattern left blank */]>; - -def UQSAX : AQI<0b01100110, 0b0101, "uqsax", - [/* For disassembly only; pattern left blank */]>; - -def UQSUB16 : AQI<0b01100110, 0b0111, "uqsub16", - [/* For disassembly only; pattern left blank */]>; - -def UQSUB8 : AQI<0b01100110, 0b1111, "uqsub8", - [/* For disassembly only; pattern left blank */]>; +def QADD : AQI<0b00010000, 0b0101, "qadd">; +def QADD16 : AQI<0b01100010, 0b0001, "qadd16">; +def QADD8 : AQI<0b01100010, 0b1001, "qadd8">; +def QASX : AQI<0b01100010, 0b0011, "qasx">; +def QDADD : AQI<0b00010100, 0b0101, "qdadd">; +def QDSUB : AQI<0b00010110, 0b0101, "qdsub">; +def QSAX : AQI<0b01100010, 0b0101, "qsax">; +def QSUB : AQI<0b00010010, 0b0101, "qsub">; +def QSUB16 : AQI<0b01100010, 0b0111, "qsub16">; +def QSUB8 : AQI<0b01100010, 0b1111, "qsub8">; +def UQADD16 : AQI<0b01100110, 0b0001, "uqadd16">; +def UQADD8 : AQI<0b01100110, 0b1001, "uqadd8">; +def UQASX : AQI<0b01100110, 0b0011, "uqasx">; +def UQSAX : AQI<0b01100110, 0b0101, "uqsax">; +def UQSUB16 : AQI<0b01100110, 0b0111, "uqsub16">; +def UQSUB8 : AQI<0b01100110, 0b1111, "uqsub8">; //===----------------------------------------------------------------------===// // Bitwise Instructions. From bob.wilson at apple.com Mon Feb 15 17:45:50 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 15 Feb 2010 15:45:50 -0800 Subject: [llvm-commits] [llvm] r96153 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td In-Reply-To: <201002140632.o1E6WLAJ008210@zion.cs.uiuc.edu> References: <201002140632.o1E6WLAJ008210@zion.cs.uiuc.edu> Message-ID: <2F110F5C-40A8-4732-9B41-784604F39B75@apple.com> I moved the empty pattern into the AQI class, too. I guess it's not worth the effort of using a multiclass here, but keep that option in mind if you encounter similar instructions in the future. On Feb 13, 2010, at 10:32 PM, Johnny Chen wrote: > Author: johnny > Date: Sun Feb 14 00:32:20 2010 > New Revision: 96153 > > URL: http://llvm.org/viewvc/llvm-project?rev=96153&view=rev > Log: > Try to factorize the specification of saturating add/subtract operations a bit, > as suggested by Bob Wilson. > > Modified: > llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96153&r1=96152&r2=96153&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Sun Feb 14 00:32:20 2010 > @@ -1360,76 +1360,61 @@ > > // Saturating adds/subtracts -- for disassembly only > > -class AQI op27_20, bits<4> op7_4, dag oops, dag iops, Format f, > - InstrItinClass itin, string opc, string asm, list pattern> > - : AI { > +// GPR:$dst = GPR:$a op GPR:$b > +class AQI op27_20, bits<4> op7_4, string opc, list pattern> > + : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, IIC_iALUr, > + opc, "\t$dst, $a, $b", pattern> { > let Inst{27-20} = op27_20; > let Inst{7-4} = op7_4; > } > > -def QADD : AQI<0b00010000, 0b0101, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qadd", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QADD16 : AQI<0b01100010, 0b0001,(outs GPR:$dst),(ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qadd16", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QADD8 : AQI<0b01100010, 0b1001, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qadd8", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QASX : AQI<0b01100010, 0b0011, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qasx", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QDADD : AQI<0b00010100, 0b0101,(outs GPR:$dst),(ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qdadd", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QDSUB : AQI<0b00010110, 0b0101,(outs GPR:$dst),(ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qdsub", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QSAX : AQI<0b01100010, 0b0101, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qsax", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QSUB : AQI<0b00010010, 0b0101, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qsub", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QSUB16 : AQI<0b01100010, 0b0111,(outs GPR:$dst),(ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qsub16", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def QSUB8 : AQI<0b01100010, 0b1111,(outs GPR:$dst),(ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "qsub8", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def UQADD16 : AQI<0b01100110, 0b0001,(outs GPR:$dst),(ins GPR:$a, GPR:$b),DPFrm, > - IIC_iALUr, "uqadd16", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def UQADD8 : AQI<0b01100110, 0b1001,(outs GPR:$dst),(ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "uqadd8", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def UQASX : AQI<0b01100110, 0b0011, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "uqasx", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def UQSAX : AQI<0b01100110, 0b0101, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "uqsax", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def UQSUB16 : AQI<0b01100110, 0b0111,(outs GPR:$dst),(ins GPR:$a, GPR:$b),DPFrm, > - IIC_iALUr, "uqsub16", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > - > -def UQSUB8 : AQI<0b01100110, 0b1111,(outs GPR:$dst),(ins GPR:$a, GPR:$b), DPFrm, > - IIC_iALUr, "uqsub8", "\t$dst, $a, $b", > - [/* For disassembly only; pattern left blank */]>; > +def QADD : AQI<0b00010000, 0b0101, "qadd", > + [/* For disassembly only; pattern left blank */]>; > + > +def QADD16 : AQI<0b01100010, 0b0001, "qadd16", > + [/* For disassembly only; pattern left blank */]>; > + > +def QADD8 : AQI<0b01100010, 0b1001, "qadd8", > + [/* For disassembly only; pattern left blank */]>; > + > +def QASX : AQI<0b01100010, 0b0011, "qasx", > + [/* For disassembly only; pattern left blank */]>; > + > +def QDADD : AQI<0b00010100, 0b0101, "qdadd", > + [/* For disassembly only; pattern left blank */]>; > + > +def QDSUB : AQI<0b00010110, 0b0101, "qdsub", > + [/* For disassembly only; pattern left blank */]>; > + > +def QSAX : AQI<0b01100010, 0b0101, "qsax", > + [/* For disassembly only; pattern left blank */]>; > + > +def QSUB : AQI<0b00010010, 0b0101, "qsub", > + [/* For disassembly only; pattern left blank */]>; > + > +def QSUB16 : AQI<0b01100010, 0b0111, "qsub16", > + [/* For disassembly only; pattern left blank */]>; > + > +def QSUB8 : AQI<0b01100010, 0b1111, "qsub8", > + [/* For disassembly only; pattern left blank */]>; > + > +def UQADD16 : AQI<0b01100110, 0b0001, "uqadd16", > + [/* For disassembly only; pattern left blank */]>; > + > +def UQADD8 : AQI<0b01100110, 0b1001, "uqadd8", > + [/* For disassembly only; pattern left blank */]>; > + > +def UQASX : AQI<0b01100110, 0b0011, "uqasx", > + [/* For disassembly only; pattern left blank */]>; > + > +def UQSAX : AQI<0b01100110, 0b0101, "uqsax", > + [/* For disassembly only; pattern left blank */]>; > + > +def UQSUB16 : AQI<0b01100110, 0b0111, "uqsub16", > + [/* For disassembly only; pattern left blank */]>; > + > +def UQSUB8 : AQI<0b01100110, 0b1111, "uqsub8", > + [/* For disassembly only; pattern left blank */]>; > > //===----------------------------------------------------------------------===// > // Bitwise Instructions. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From john at bass-software.com Mon Feb 15 17:48:47 2010 From: john at bass-software.com (John Tytgat) Date: Tue, 16 Feb 2010 00:48:47 +0100 Subject: [llvm-commits] Support for ARMv4 In-Reply-To: References: <698345e950.Jo@hobbes.bass-software.com> Message-ID: <30e333ea50.Jo@hobbes.bass-software.com> In message Anton Korobeynikov wrote: > Hello, John > > > No regressions for 'make TESTSUITE=CodeGen/ARM check'. > This is pretty expected and necessary thing, but not sufficient. > > Could you please compile llvm-gcc as a cross-compiler for ARMv4? Even > better, with newlib compiled at the same time. This will ensure that > the v4 support is indeed real. Sure, and thanks for this useful suggestion. It allowed me to finetune a couple of things ;-) Attached two patches, one for llvm and one for llvm-gcc: llvm-armv4.patch: - lib/Target/ARM/ARMSubtarget.cpp(ARMSubtarget::ARMSubtarget): Make triple armv4-* switch ARMArchVersion to V4, allow CPU selection (like strongarm) to switch to V4 as well but keep ARMv4T still as default when no arch is specified. - lib/Target/ARM/ARMSubtarget.h(V4): Defined. - lib/Target/ARM/ARMInstrInfo.td(HasV4T,NoV4T): Define. (BX_RET): Add IsARM and HasV4T requirements. (MOVPCLR): Define, is equivalent to BX_RET but for ARMv4 only. (BRIND): Add IsARM and HasV4T requirements. (MOVPCRX): Define, is equivalent to BRIND but for ARMv4 only. (BX, BXr9): Add HasV4T requirements. (BMOVPCRX): Define, is equivalent to BX but for ARMv4 only. (BMOVPCRXr9): Define, is equivalent to BXr9 but for ARMv4 only. - lib/Target/ARM/ARMCodeEmitter.cpp(ARMCodeEmitter::emitMiscBranchInstruction): Take ARM::MOVPCLR into account. - lib/Target/ARM/ARMBaseInstrInfo.h(isIndirectBranchOpcode): Take ARM::MOVPCRX into account. - test/CodeGen/ARM/armv4.ll: Added test case. llvm-gcc-armv4.patch: - gcc/config/arm/arm.h(LLVM_OVERRIDE_TARGET_ARCH): Add check for arm_arch4. - gcc/config/arm/libunwind.S(gnu_Unwind_Restore_WMMXC,gnu_Unwind_Save_WMMXC): Avoid binutils error when selecting a pre-ARMv5 arch. No regressions for 'make TESTSUITE=CodeGen/ARM check'. Tested with llvm-gcc target arm-unknown-eabi + newlib 1.18, binutils 2.20 and configured with --with-arch=armv4 John. -- John Tytgat John at bass-software.com -------------- next part -------------- Index: lib/Target/ARM/ARMSubtarget.cpp =================================================================== --- lib/Target/ARM/ARMSubtarget.cpp (revision 96176) +++ lib/Target/ARM/ARMSubtarget.cpp (working copy) @@ -33,7 +33,7 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS, bool isT) - : ARMArchVersion(V4T) + : ARMArchVersion(V4) , ARMFPUType(None) , UseNEONForSinglePrecisionFP(UseNEONFP) , IsThumb(isT) @@ -54,6 +54,11 @@ // Parse features string. CPUString = ParseSubtargetFeatures(FS, CPUString); + // When no arch is specified either by CPU or by attributes, make the default + // ARMv4T. + if (CPUString == "generic" && (FS.empty() || FS == "generic")) + ARMArchVersion = V4T; + // Set the boolean corresponding to the current target triple, or the default // if one cannot be determined, to true. unsigned Len = TT.length(); @@ -68,25 +73,28 @@ } if (Idx) { unsigned SubVer = TT[Idx]; - if (SubVer > '4' && SubVer <= '9') { - if (SubVer >= '7') { - ARMArchVersion = V7A; - } else if (SubVer == '6') { - ARMArchVersion = V6; - if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2') - ARMArchVersion = V6T2; - } else if (SubVer == '5') { - ARMArchVersion = V5T; - if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e') - ARMArchVersion = V5TE; - } - if (ARMArchVersion >= V6T2) - ThumbMode = Thumb2; + if (SubVer >= '7' && SubVer <= '9') { + ARMArchVersion = V7A; + } else if (SubVer == '6') { + ARMArchVersion = V6; + if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2') + ARMArchVersion = V6T2; + } else if (SubVer == '5') { + ARMArchVersion = V5T; + if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e') + ARMArchVersion = V5TE; + } else if (SubVer == '4') { + if (Len >= Idx+2 && TT[Idx+1] == 't') + ARMArchVersion = V4T; + else + ARMArchVersion = V4; } } // Thumb2 implies at least V6T2. - if (ARMArchVersion < V6T2 && ThumbMode >= Thumb2) + if (ARMArchVersion >= V6T2) + ThumbMode = Thumb2; + else if (ThumbMode >= Thumb2) ARMArchVersion = V6T2; if (Len >= 10) { Index: lib/Target/ARM/ARMInstrInfo.td =================================================================== --- lib/Target/ARM/ARMInstrInfo.td (revision 96176) +++ lib/Target/ARM/ARMInstrInfo.td (working copy) @@ -113,6 +113,8 @@ //===----------------------------------------------------------------------===// // ARM Instruction Predicate Definitions. // +def HasV4T : Predicate<"Subtarget->hasV4TOps()">; +def NoV4T : Predicate<"!Subtarget->hasV4TOps()">; def HasV5T : Predicate<"Subtarget->hasV5TOps()">; def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">; def HasV6 : Predicate<"Subtarget->hasV6Ops()">; @@ -770,24 +772,50 @@ // Control Flow Instructions. // -let isReturn = 1, isTerminator = 1, isBarrier = 1 in +let isReturn = 1, isTerminator = 1, isBarrier = 1 in { + // ARMV4T and above def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br, - "bx", "\tlr", [(ARMretflag)]> { - let Inst{3-0} = 0b1110; - let Inst{7-4} = 0b0001; - let Inst{19-8} = 0b111111111111; - let Inst{27-20} = 0b00010010; + "bx", "\tlr", [(ARMretflag)]>, + Requires<[IsARM, HasV4T]> { + let Inst{3-0} = 0b1110; + let Inst{7-4} = 0b0001; + let Inst{19-8} = 0b111111111111; + let Inst{27-20} = 0b00010010; + } + + // ARMV4 only + def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br, + "mov", "\tpc, lr", [(ARMretflag)]>, + Requires<[IsARM, NoV4T]> { + let Inst{11-0} = 0b000000001110; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + } } // Indirect branches let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { + // ARMV4T and above def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst", - [(brind GPR:$dst)]> { + [(brind GPR:$dst)]>, + Requires<[IsARM, HasV4T]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; let Inst{27-20} = 0b00010010; let Inst{31-28} = 0b1110; } + + // ARMV4 only + def MOVPCRX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "mov\tpc, $dst", + [(brind GPR:$dst)]>, + Requires<[IsARM, NoV4T]> { + let Inst{11-4} = 0b00000000; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + let Inst{31-28} = 0b1110; + } } // FIXME: remove when we have a way to marking a MI with these properties. @@ -831,11 +859,22 @@ def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", [(ARMcall_nolink GPR:$func)]>, - Requires<[IsARM, IsNotDarwin]> { + Requires<[IsARM, HasV4T, IsNotDarwin]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; let Inst{27-20} = 0b00010010; } + + // ARMv4 + def BMOVPCRX : ABXIx2<(outs), (ins GPR:$func, variable_ops), + IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func", + [(ARMcall_nolink GPR:$func)]>, + Requires<[IsARM, NoV4T, IsNotDarwin]> { + let Inst{11-4} = 0b00000000; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + } } // On Darwin R9 is call-clobbered. @@ -867,11 +906,23 @@ // ARMv4T def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", - [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> { + [(ARMcall_nolink GPR:$func)]>, + Requires<[IsARM, HasV4T, IsDarwin]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; let Inst{27-20} = 0b00010010; } + + // ARMv4 + def BMOVPCRXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops), + IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func", + [(ARMcall_nolink GPR:$func)]>, + Requires<[IsARM, NoV4T, IsDarwin]> { + let Inst{11-4} = 0b00000000; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + } } let isBranch = 1, isTerminator = 1 in { Index: lib/Target/ARM/ARMCodeEmitter.cpp =================================================================== --- lib/Target/ARM/ARMCodeEmitter.cpp (revision 96176) +++ lib/Target/ARM/ARMCodeEmitter.cpp (working copy) @@ -1138,7 +1138,7 @@ // Set the conditional execution predicate Binary |= II->getPredicate(&MI) << ARMII::CondShift; - if (TID.Opcode == ARM::BX_RET) + if (TID.Opcode == (Subtarget->hasV4TOps() ? ARM::BX_RET : ARM::MOVPCLR)) // The return register is LR. Binary |= ARMRegisterInfo::getRegisterNumbering(ARM::LR); else Index: lib/Target/ARM/ARMSubtarget.h =================================================================== --- lib/Target/ARM/ARMSubtarget.h (revision 96176) +++ lib/Target/ARM/ARMSubtarget.h (working copy) @@ -26,7 +26,7 @@ class ARMSubtarget : public TargetSubtarget { protected: enum ARMArchEnum { - V4T, V5T, V5TE, V6, V6T2, V7A + V4, V4T, V5T, V5TE, V6, V6T2, V7A }; enum ARMFPEnum { @@ -38,7 +38,7 @@ Thumb2 }; - /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE, + /// ARMArchVersion - ARM architecture version: V4, V4T (base), V5T, V5TE, /// V6, V6T2, V7A. ARMArchEnum ARMArchVersion; Index: lib/Target/ARM/ARMBaseInstrInfo.h =================================================================== --- lib/Target/ARM/ARMBaseInstrInfo.h (revision 96176) +++ lib/Target/ARM/ARMBaseInstrInfo.h (working copy) @@ -332,7 +332,7 @@ static inline bool isIndirectBranchOpcode(int Opc) { - return Opc == ARM::BRIND || Opc == ARM::tBRIND; + return Opc == ARM::BRIND || Opc == ARM::MOVPCRX || Opc == ARM::tBRIND; } /// getInstrPredicate - If instruction is predicated, returns its predicate -------------- next part -------------- Index: gcc/config/arm/arm.h =================================================================== --- gcc/config/arm/arm.h (revision 96176) +++ gcc/config/arm/arm.h (working copy) @@ -3519,7 +3519,9 @@ : (arm_arch5 \ ? "armv5" \ : (arm_arch4t \ - ? "armv4t" : ""))))))) + ? "armv4t" \ + : (arm_arch4 \ + ? "armv4" : "")))))))) #define LLVM_SET_MACHINE_OPTIONS(argvec) \ if (TARGET_SOFT_FLOAT) \ Index: gcc/config/arm/libunwind.S =================================================================== --- gcc/config/arm/libunwind.S (revision 96176) +++ gcc/config/arm/libunwind.S (working copy) @@ -167,21 +167,37 @@ RET ARM_FUNC_START gnu_Unwind_Restore_WMMXC +#if __ARM_ARCH__ > 4 /* Use the generic coprocessor form so that gas doesn't complain on non-iWMMXt targets. */ ldc2 p1, cr8, [r0], #4 /* wldrw wcgr0, [r0], #4 */ ldc2 p1, cr9, [r0], #4 /* wldrw wcgr1, [r0], #4 */ ldc2 p1, cr10, [r0], #4 /* wldrw wcgr2, [r0], #4 */ ldc2 p1, cr11, [r0], #4 /* wldrw wcgr3, [r0], #4 */ +#else + /* ldc2 is not valid pre-ARMv5 */ + .word 0xfcb08101 + .word 0xfcb09101 + .word 0xfcb0a101 + .word 0xfcb0b101 +#endif RET ARM_FUNC_START gnu_Unwind_Save_WMMXC +#if __ARM_ARCH__ > 4 /* Use the generic coprocessor form so that gas doesn't complain on non-iWMMXt targets. */ stc2 p1, cr8, [r0], #4 /* wstrw wcgr0, [r0], #4 */ stc2 p1, cr9, [r0], #4 /* wstrw wcgr1, [r0], #4 */ stc2 p1, cr10, [r0], #4 /* wstrw wcgr2, [r0], #4 */ stc2 p1, cr11, [r0], #4 /* wstrw wcgr3, [r0], #4 */ +#else + /* stc2 is not valid pre-ARMv5 */ + .word 0xfca08101 + .word 0xfca09101 + .word 0xfca0a101 + .word 0xfca0b101 +#endif RET /* APPLE LOCAL end v7 support. Merge from Codesourcery */ From john at bass-software.com Mon Feb 15 17:57:14 2010 From: john at bass-software.com (John Tytgat) Date: Tue, 16 Feb 2010 00:57:14 +0100 Subject: [llvm-commits] Support for ARMv4 In-Reply-To: <30e333ea50.Jo@hobbes.bass-software.com> References: <698345e950.Jo@hobbes.bass-software.com> <30e333ea50.Jo@hobbes.bass-software.com> Message-ID: <74a934ea50.Jo@hobbes.bass-software.com> In message <30e333ea50.Jo at hobbes.bass-software.com> John Tytgat wrote: > In message > Anton Korobeynikov wrote: > > > Hello, John > > > > > No regressions for 'make TESTSUITE=CodeGen/ARM check'. > > This is pretty expected and necessary thing, but not sufficient. > > > > Could you please compile llvm-gcc as a cross-compiler for ARMv4? Even > > better, with newlib compiled at the same time. This will ensure that > > the v4 support is indeed real. > > Sure, and thanks for this useful suggestion. It allowed me to finetune > a couple of things ;-) Attached two patches, one for llvm and one for > llvm-gcc: > > llvm-armv4.patch: > [...] > - test/CodeGen/ARM/armv4.ll: Added test case. > > llvm-gcc-armv4.patch: Apologies, I just see the armv4.ll testcase wasn't included. Attached the two patches again with that fixed. John. -- John Tytgat John at bass-software.com -------------- next part -------------- Index: test/CodeGen/ARM/armv4.ll =================================================================== --- test/CodeGen/ARM/armv4.ll (revision 0) +++ test/CodeGen/ARM/armv4.ll (revision 0) @@ -0,0 +1,13 @@ +; RUN: llc < %s -mtriple=arm-unknown-eabi | FileCheck %s -check-prefix=THUMB +; RUN: llc < %s -mtriple=arm-unknown-eabi -mcpu=strongarm | FileCheck %s -check-prefix=ARM +; RUN: llc < %s -mtriple=arm-unknown-eabi -mcpu=cortex-a8 | FileCheck %s -check-prefix=THUMB +; RUN: llc < %s -mtriple=arm-unknown-eabi -mattr=+v6 | FileCheck %s -check-prefix=THUMB +; RUN: llc < %s -mtriple=armv4-unknown-eabi | FileCheck %s -check-prefix=ARM +; RUN: llc < %s -mtriple=armv4t-unknown-eabi | FileCheck %s -check-prefix=THUMB + +define arm_aapcscc i32 @test(i32 %a) nounwind readnone { +entry: +; ARM: mov pc +; THUMB: bx + ret i32 %a +} Index: lib/Target/ARM/ARMSubtarget.cpp =================================================================== --- lib/Target/ARM/ARMSubtarget.cpp (revision 96176) +++ lib/Target/ARM/ARMSubtarget.cpp (working copy) @@ -33,7 +33,7 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &FS, bool isT) - : ARMArchVersion(V4T) + : ARMArchVersion(V4) , ARMFPUType(None) , UseNEONForSinglePrecisionFP(UseNEONFP) , IsThumb(isT) @@ -54,6 +54,11 @@ // Parse features string. CPUString = ParseSubtargetFeatures(FS, CPUString); + // When no arch is specified either by CPU or by attributes, make the default + // ARMv4T. + if (CPUString == "generic" && (FS.empty() || FS == "generic")) + ARMArchVersion = V4T; + // Set the boolean corresponding to the current target triple, or the default // if one cannot be determined, to true. unsigned Len = TT.length(); @@ -68,25 +73,28 @@ } if (Idx) { unsigned SubVer = TT[Idx]; - if (SubVer > '4' && SubVer <= '9') { - if (SubVer >= '7') { - ARMArchVersion = V7A; - } else if (SubVer == '6') { - ARMArchVersion = V6; - if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2') - ARMArchVersion = V6T2; - } else if (SubVer == '5') { - ARMArchVersion = V5T; - if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e') - ARMArchVersion = V5TE; - } - if (ARMArchVersion >= V6T2) - ThumbMode = Thumb2; + if (SubVer >= '7' && SubVer <= '9') { + ARMArchVersion = V7A; + } else if (SubVer == '6') { + ARMArchVersion = V6; + if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == '2') + ARMArchVersion = V6T2; + } else if (SubVer == '5') { + ARMArchVersion = V5T; + if (Len >= Idx+3 && TT[Idx+1] == 't' && TT[Idx+2] == 'e') + ARMArchVersion = V5TE; + } else if (SubVer == '4') { + if (Len >= Idx+2 && TT[Idx+1] == 't') + ARMArchVersion = V4T; + else + ARMArchVersion = V4; } } // Thumb2 implies at least V6T2. - if (ARMArchVersion < V6T2 && ThumbMode >= Thumb2) + if (ARMArchVersion >= V6T2) + ThumbMode = Thumb2; + else if (ThumbMode >= Thumb2) ARMArchVersion = V6T2; if (Len >= 10) { Index: lib/Target/ARM/ARMInstrInfo.td =================================================================== --- lib/Target/ARM/ARMInstrInfo.td (revision 96176) +++ lib/Target/ARM/ARMInstrInfo.td (working copy) @@ -113,6 +113,8 @@ //===----------------------------------------------------------------------===// // ARM Instruction Predicate Definitions. // +def HasV4T : Predicate<"Subtarget->hasV4TOps()">; +def NoV4T : Predicate<"!Subtarget->hasV4TOps()">; def HasV5T : Predicate<"Subtarget->hasV5TOps()">; def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">; def HasV6 : Predicate<"Subtarget->hasV6Ops()">; @@ -770,24 +772,50 @@ // Control Flow Instructions. // -let isReturn = 1, isTerminator = 1, isBarrier = 1 in +let isReturn = 1, isTerminator = 1, isBarrier = 1 in { + // ARMV4T and above def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br, - "bx", "\tlr", [(ARMretflag)]> { - let Inst{3-0} = 0b1110; - let Inst{7-4} = 0b0001; - let Inst{19-8} = 0b111111111111; - let Inst{27-20} = 0b00010010; + "bx", "\tlr", [(ARMretflag)]>, + Requires<[IsARM, HasV4T]> { + let Inst{3-0} = 0b1110; + let Inst{7-4} = 0b0001; + let Inst{19-8} = 0b111111111111; + let Inst{27-20} = 0b00010010; + } + + // ARMV4 only + def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br, + "mov", "\tpc, lr", [(ARMretflag)]>, + Requires<[IsARM, NoV4T]> { + let Inst{11-0} = 0b000000001110; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + } } // Indirect branches let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { + // ARMV4T and above def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst", - [(brind GPR:$dst)]> { + [(brind GPR:$dst)]>, + Requires<[IsARM, HasV4T]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; let Inst{27-20} = 0b00010010; let Inst{31-28} = 0b1110; } + + // ARMV4 only + def MOVPCRX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "mov\tpc, $dst", + [(brind GPR:$dst)]>, + Requires<[IsARM, NoV4T]> { + let Inst{11-4} = 0b00000000; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + let Inst{31-28} = 0b1110; + } } // FIXME: remove when we have a way to marking a MI with these properties. @@ -831,11 +859,22 @@ def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", [(ARMcall_nolink GPR:$func)]>, - Requires<[IsARM, IsNotDarwin]> { + Requires<[IsARM, HasV4T, IsNotDarwin]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; let Inst{27-20} = 0b00010010; } + + // ARMv4 + def BMOVPCRX : ABXIx2<(outs), (ins GPR:$func, variable_ops), + IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func", + [(ARMcall_nolink GPR:$func)]>, + Requires<[IsARM, NoV4T, IsNotDarwin]> { + let Inst{11-4} = 0b00000000; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + } } // On Darwin R9 is call-clobbered. @@ -867,11 +906,23 @@ // ARMv4T def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", - [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> { + [(ARMcall_nolink GPR:$func)]>, + Requires<[IsARM, HasV4T, IsDarwin]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; let Inst{27-20} = 0b00010010; } + + // ARMv4 + def BMOVPCRXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops), + IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func", + [(ARMcall_nolink GPR:$func)]>, + Requires<[IsARM, NoV4T, IsDarwin]> { + let Inst{11-4} = 0b00000000; + let Inst{15-12} = 0b1111; + let Inst{19-16} = 0b0000; + let Inst{27-20} = 0b00011010; + } } let isBranch = 1, isTerminator = 1 in { Index: lib/Target/ARM/ARMCodeEmitter.cpp =================================================================== --- lib/Target/ARM/ARMCodeEmitter.cpp (revision 96176) +++ lib/Target/ARM/ARMCodeEmitter.cpp (working copy) @@ -1138,7 +1138,7 @@ // Set the conditional execution predicate Binary |= II->getPredicate(&MI) << ARMII::CondShift; - if (TID.Opcode == ARM::BX_RET) + if (TID.Opcode == (Subtarget->hasV4TOps() ? ARM::BX_RET : ARM::MOVPCLR)) // The return register is LR. Binary |= ARMRegisterInfo::getRegisterNumbering(ARM::LR); else Index: lib/Target/ARM/ARMSubtarget.h =================================================================== --- lib/Target/ARM/ARMSubtarget.h (revision 96176) +++ lib/Target/ARM/ARMSubtarget.h (working copy) @@ -26,7 +26,7 @@ class ARMSubtarget : public TargetSubtarget { protected: enum ARMArchEnum { - V4T, V5T, V5TE, V6, V6T2, V7A + V4, V4T, V5T, V5TE, V6, V6T2, V7A }; enum ARMFPEnum { @@ -38,7 +38,7 @@ Thumb2 }; - /// ARMArchVersion - ARM architecture version: V4T (base), V5T, V5TE, + /// ARMArchVersion - ARM architecture version: V4, V4T (base), V5T, V5TE, /// V6, V6T2, V7A. ARMArchEnum ARMArchVersion; Index: lib/Target/ARM/ARMBaseInstrInfo.h =================================================================== --- lib/Target/ARM/ARMBaseInstrInfo.h (revision 96176) +++ lib/Target/ARM/ARMBaseInstrInfo.h (working copy) @@ -332,7 +332,7 @@ static inline bool isIndirectBranchOpcode(int Opc) { - return Opc == ARM::BRIND || Opc == ARM::tBRIND; + return Opc == ARM::BRIND || Opc == ARM::MOVPCRX || Opc == ARM::tBRIND; } /// getInstrPredicate - If instruction is predicated, returns its predicate -------------- next part -------------- Index: gcc/config/arm/arm.h =================================================================== --- gcc/config/arm/arm.h (revision 96176) +++ gcc/config/arm/arm.h (working copy) @@ -3519,7 +3519,9 @@ : (arm_arch5 \ ? "armv5" \ : (arm_arch4t \ - ? "armv4t" : ""))))))) + ? "armv4t" \ + : (arm_arch4 \ + ? "armv4" : "")))))))) #define LLVM_SET_MACHINE_OPTIONS(argvec) \ if (TARGET_SOFT_FLOAT) \ Index: gcc/config/arm/libunwind.S =================================================================== --- gcc/config/arm/libunwind.S (revision 96176) +++ gcc/config/arm/libunwind.S (working copy) @@ -167,21 +167,37 @@ RET ARM_FUNC_START gnu_Unwind_Restore_WMMXC +#if __ARM_ARCH__ > 4 /* Use the generic coprocessor form so that gas doesn't complain on non-iWMMXt targets. */ ldc2 p1, cr8, [r0], #4 /* wldrw wcgr0, [r0], #4 */ ldc2 p1, cr9, [r0], #4 /* wldrw wcgr1, [r0], #4 */ ldc2 p1, cr10, [r0], #4 /* wldrw wcgr2, [r0], #4 */ ldc2 p1, cr11, [r0], #4 /* wldrw wcgr3, [r0], #4 */ +#else + /* ldc2 is not valid pre-ARMv5 */ + .word 0xfcb08101 + .word 0xfcb09101 + .word 0xfcb0a101 + .word 0xfcb0b101 +#endif RET ARM_FUNC_START gnu_Unwind_Save_WMMXC +#if __ARM_ARCH__ > 4 /* Use the generic coprocessor form so that gas doesn't complain on non-iWMMXt targets. */ stc2 p1, cr8, [r0], #4 /* wstrw wcgr0, [r0], #4 */ stc2 p1, cr9, [r0], #4 /* wstrw wcgr1, [r0], #4 */ stc2 p1, cr10, [r0], #4 /* wstrw wcgr2, [r0], #4 */ stc2 p1, cr11, [r0], #4 /* wstrw wcgr3, [r0], #4 */ +#else + /* stc2 is not valid pre-ARMv5 */ + .word 0xfca08101 + .word 0xfca09101 + .word 0xfca0a101 + .word 0xfca0b101 +#endif RET /* APPLE LOCAL end v7 support. Merge from Codesourcery */ From clattner at apple.com Mon Feb 15 18:04:19 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Feb 2010 16:04:19 -0800 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp In-Reply-To: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> References: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> Message-ID: Isn't a unit test for this completely overkill? -Chris On Feb 15, 2010, at 2:09 PM, Nick Lewycky wrote: > Author: nicholas > Date: Mon Feb 15 16:09:09 2010 > New Revision: 96282 > > URL: http://llvm.org/viewvc/llvm-project?rev=96282&view=rev > Log: > Teach the verifier to check the condition on a branch and ensure that it has > 'i1' type. > > Added: > llvm/trunk/unittests/VMCore/VerifierTest.cpp > Modified: > llvm/trunk/lib/VMCore/Verifier.cpp > > Modified: llvm/trunk/lib/VMCore/Verifier.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96282&r1=96281&r2=96282&view=diff > > ============================================================================== > --- llvm/trunk/lib/VMCore/Verifier.cpp (original) > +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Feb 15 16:09:09 2010 > @@ -317,6 +317,7 @@ > void visitStoreInst(StoreInst &SI); > void visitInstruction(Instruction &I); > void visitTerminatorInst(TerminatorInst &I); > + void visitBranchInst(BranchInst &BI); > void visitReturnInst(ReturnInst &RI); > void visitSwitchInst(SwitchInst &SI); > void visitSelectInst(SelectInst &SI); > @@ -749,6 +750,14 @@ > visitInstruction(I); > } > > +void Verifier::visitBranchInst(BranchInst &BI) { > + if (BI.isConditional()) { > + Assert2(BI.getCondition()->getType()->isIntegerTy(1), > + "Branch condition is not 'i1' type!", &BI, BI.getCondition()); > + } > + visitTerminatorInst(BI); > +} > + > void Verifier::visitReturnInst(ReturnInst &RI) { > Function *F = RI.getParent()->getParent(); > unsigned N = RI.getNumOperands(); > > Added: llvm/trunk/unittests/VMCore/VerifierTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/VerifierTest.cpp?rev=96282&view=auto > > ============================================================================== > --- llvm/trunk/unittests/VMCore/VerifierTest.cpp (added) > +++ llvm/trunk/unittests/VMCore/VerifierTest.cpp Mon Feb 15 16:09:09 2010 > @@ -0,0 +1,44 @@ > +//===- llvm/unittest/VMCore/VerifierTest.cpp - Verifier unit tests --------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/Constants.h" > +#include "llvm/DerivedTypes.h" > +#include "llvm/Function.h" > +#include "llvm/Instructions.h" > +#include "llvm/LLVMContext.h" > +#include "llvm/Analysis/Verifier.h" > +#include "gtest/gtest.h" > + > +namespace llvm { > +namespace { > + > +TEST(VerifierTest, Branch_i1) { > + LLVMContext &C = getGlobalContext(); > + FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); > + Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage); > + BasicBlock *Entry = BasicBlock::Create(C, "entry", F); > + BasicBlock *Exit = BasicBlock::Create(C, "exit", F); > + ReturnInst::Create(C, Exit); > + > + // To avoid triggering an assertion in BranchInst::Create, we first create > + // a branch with an 'i1' condition ... > + > + Constant *False = ConstantInt::getFalse(C); > + BranchInst *BI = BranchInst::Create(Exit, Exit, False, Entry); > + > + // ... then use setOperand to redirect it to a value of different type. > + > + Constant *Zero32 = ConstantInt::get(IntegerType::get(C, 32), 0); > + BI->setOperand(0, Zero32); > + > + EXPECT_TRUE(verifyFunction(*F, ReturnStatusAction)); > +} > + > +} > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From tilmann.scheller at googlemail.com Mon Feb 15 18:17:11 2010 From: tilmann.scheller at googlemail.com (Tilmann Scheller) Date: Tue, 16 Feb 2010 01:17:11 +0100 Subject: [llvm-commits] [ppc linux] Drop support for the InReg attribute In-Reply-To: <38a0d8451002151516m4f65b6a6p1d4caaca28b2ef52@mail.gmail.com> References: <38a0d8451002151516m4f65b6a6p1d4caaca28b2ef52@mail.gmail.com> Message-ID: Hi Rafael, On Tue, Feb 16, 2010 at 12:16 AM, Rafael Espindola wrote: > The attached patch drops support for the InReg attribute in the ppc > linux backend. It is no longer used by llvm-gcc. There were no tests > for this feature, so make check-lit is clean. Looks good, please commit! Thanks for working on the removal of this hack :) Cheers, Tilmann From alenhar2 at cs.uiuc.edu Mon Feb 15 18:19:24 2010 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 16 Feb 2010 00:19:24 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96300 - /llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h Message-ID: <201002160019.o1G0JO86029628@zion.cs.uiuc.edu> Author: alenhar2 Date: Mon Feb 15 18:19:23 2010 New Revision: 96300 URL: http://llvm.org/viewvc/llvm-project?rev=96300&view=rev Log: Turn off 128 bit FP on alpha for now, fixes, in a way, Bug 6235 Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h?rev=96300&r1=96299&r2=96300&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h Mon Feb 15 18:19:23 2010 @@ -20,6 +20,13 @@ the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +/* LLVM LOCAL begin */ +#ifdef ENABLE_LLVM +#undef TARGET_LONG_DOUBLE_128 +#define TARGET_LONG_DOUBLE_128 0 +#endif +/* LLVM LOCAL end */ + /* Target CPU builtins. */ #define TARGET_CPU_CPP_BUILTINS() \ do \ @@ -1605,6 +1612,7 @@ */ #define LLVM_TARGET_NAME Alpha +#define TARGET_ALPHA /* LLVM_TARGET_INTRINSIC_LOWER - To handle builtins, we want to expand the * invocation into normal LLVM code. If the target can handle the builtin, this From gohman at apple.com Mon Feb 15 18:20:08 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Feb 2010 00:20:08 -0000 Subject: [llvm-commits] [llvm] r96301 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <201002160020.o1G0K8RG029693@zion.cs.uiuc.edu> Author: djg Date: Mon Feb 15 18:20:08 2010 New Revision: 96301 URL: http://llvm.org/viewvc/llvm-project?rev=96301&view=rev Log: When reusing an existing PHI node in a loop, be even more strict about the requirements. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=96301&r1=96300&r2=96301&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Feb 15 18:20:08 2010 @@ -646,18 +646,46 @@ SE.getEffectiveSCEVType(Normalized->getType())) && SE.getSCEV(PN) == Normalized) if (BasicBlock *LatchBlock = L->getLoopLatch()) { - // Remember this PHI, even in post-inc mode. - InsertedValues.insert(PN); - // Remember the increment. Instruction *IncV = - cast(PN->getIncomingValueForBlock(LatchBlock) - ->stripPointerCasts()); - rememberInstruction(IncV); - // Make sure the increment is where we want it. But don't move it - // down past a potential existing post-inc user. - if (L == IVIncInsertLoop && !SE.DT->dominates(IncV, IVIncInsertPos)) - IncV->moveBefore(IVIncInsertPos); - return PN; + cast(PN->getIncomingValueForBlock(LatchBlock)); + + // Determine if this is a well-behaved chain of instructions leading + // back to the PHI. It probably will be, if we're scanning an inner + // loop already visited by LSR for example, but it wouldn't have + // to be. + do { + if (IncV->getNumOperands() == 0 || isa(IncV)) { + IncV = 0; + break; + } + IncV = dyn_cast(IncV->getOperand(0)); + if (!IncV) + break; + if (IncV->mayHaveSideEffects()) { + IncV = 0; + break; + } + } while (IncV != PN); + + if (IncV) { + // Ok, the add recurrence looks usable. + // Remember this PHI, even in post-inc mode. + InsertedValues.insert(PN); + // Remember the increment. + IncV = cast(PN->getIncomingValueForBlock(LatchBlock)); + rememberInstruction(IncV); + if (L == IVIncInsertLoop) + do { + if (SE.DT->dominates(IncV, IVIncInsertPos)) + break; + // Make sure the increment is where we want it. But don't move it + // down past a potential existing post-inc user. + IncV->moveBefore(IVIncInsertPos); + IVIncInsertPos = IncV; + IncV = cast(IncV->getOperand(0)); + } while (IncV != PN); + return PN; + } } // Save the original insertion point so we can restore it when we're done. From nicholas at mxc.ca Mon Feb 15 18:42:08 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 15 Feb 2010 16:42:08 -0800 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp In-Reply-To: References: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> Message-ID: <4B79E9E0.3040500@mxc.ca> Chris Lattner wrote: > Isn't a unit test for this completely overkill? Testing methodology-type people would tell you that the real problem is that the rest of the verifier is lacking tests ... ... but really, writing this test case is what led to the fixes in r96272, r96273 and r96275. Even if we didn't test this in particular, we should probably have a unit test that F->dump() and FPM.run(F) on functions that have no module owners still work. Ultimately I don't really care. Nick > > -Chris > > On Feb 15, 2010, at 2:09 PM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Mon Feb 15 16:09:09 2010 >> New Revision: 96282 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=96282&view=rev >> Log: >> Teach the verifier to check the condition on a branch and ensure that it has >> 'i1' type. >> >> Added: >> llvm/trunk/unittests/VMCore/VerifierTest.cpp >> Modified: >> llvm/trunk/lib/VMCore/Verifier.cpp >> >> Modified: llvm/trunk/lib/VMCore/Verifier.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96282&r1=96281&r2=96282&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/VMCore/Verifier.cpp (original) >> +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Feb 15 16:09:09 2010 >> @@ -317,6 +317,7 @@ >> void visitStoreInst(StoreInst&SI); >> void visitInstruction(Instruction&I); >> void visitTerminatorInst(TerminatorInst&I); >> + void visitBranchInst(BranchInst&BI); >> void visitReturnInst(ReturnInst&RI); >> void visitSwitchInst(SwitchInst&SI); >> void visitSelectInst(SelectInst&SI); >> @@ -749,6 +750,14 @@ >> visitInstruction(I); >> } >> >> +void Verifier::visitBranchInst(BranchInst&BI) { >> + if (BI.isConditional()) { >> + Assert2(BI.getCondition()->getType()->isIntegerTy(1), >> + "Branch condition is not 'i1' type!",&BI, BI.getCondition()); >> + } >> + visitTerminatorInst(BI); >> +} >> + >> void Verifier::visitReturnInst(ReturnInst&RI) { >> Function *F = RI.getParent()->getParent(); >> unsigned N = RI.getNumOperands(); >> >> Added: llvm/trunk/unittests/VMCore/VerifierTest.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/VerifierTest.cpp?rev=96282&view=auto >> >> ============================================================================== >> --- llvm/trunk/unittests/VMCore/VerifierTest.cpp (added) >> +++ llvm/trunk/unittests/VMCore/VerifierTest.cpp Mon Feb 15 16:09:09 2010 >> @@ -0,0 +1,44 @@ >> +//===- llvm/unittest/VMCore/VerifierTest.cpp - Verifier unit tests --------===// >> +// >> +// The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#include "llvm/Constants.h" >> +#include "llvm/DerivedTypes.h" >> +#include "llvm/Function.h" >> +#include "llvm/Instructions.h" >> +#include "llvm/LLVMContext.h" >> +#include "llvm/Analysis/Verifier.h" >> +#include "gtest/gtest.h" >> + >> +namespace llvm { >> +namespace { >> + >> +TEST(VerifierTest, Branch_i1) { >> + LLVMContext&C = getGlobalContext(); >> + FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); >> + Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage); >> + BasicBlock *Entry = BasicBlock::Create(C, "entry", F); >> + BasicBlock *Exit = BasicBlock::Create(C, "exit", F); >> + ReturnInst::Create(C, Exit); >> + >> + // To avoid triggering an assertion in BranchInst::Create, we first create >> + // a branch with an 'i1' condition ... >> + >> + Constant *False = ConstantInt::getFalse(C); >> + BranchInst *BI = BranchInst::Create(Exit, Exit, False, Entry); >> + >> + // ... then use setOperand to redirect it to a value of different type. >> + >> + Constant *Zero32 = ConstantInt::get(IntegerType::get(C, 32), 0); >> + BI->setOperand(0, Zero32); >> + >> + EXPECT_TRUE(verifyFunction(*F, ReturnStatusAction)); >> +} >> + >> +} >> +} >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From dalej at apple.com Mon Feb 15 18:43:59 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Feb 2010 00:43:59 -0000 Subject: [llvm-commits] [llvm] r96303 - /llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Message-ID: <201002160043.o1G0hxVi030817@zion.cs.uiuc.edu> Author: johannes Date: Mon Feb 15 18:43:58 2010 New Revision: 96303 URL: http://llvm.org/viewvc/llvm-project?rev=96303&view=rev Log: Something broke. Hard to believe it was this patch but it's harder to believe it's the other candidate, so reverting. Temporarily I hope. Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=96303&r1=96302&r2=96303&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Mon Feb 15 18:43:58 2010 @@ -490,12 +490,10 @@ // If the virtual register is already available, just update the instruction // and return. if (unsigned PR = getVirt2PhysRegMapSlot(VirtReg)) { + MarkPhysRegRecentlyUsed(PR); // Already have this value available! MI->getOperand(OpNum).setReg(PR); // Assign the input register - if (!MI->isDebugValue()) { - // Do not do these for DBG_VALUE as they can affect codegen. - MarkPhysRegRecentlyUsed(PR); // Already have this value available! + if (!MI->isDebugValue()) getVirtRegLastUse(VirtReg) = std::make_pair(MI, OpNum); - } return MI; } @@ -696,13 +694,7 @@ bool usedOutsideBlock = isPhysReg ? false : UsedInMultipleBlocks.test(MO.getReg() - TargetRegisterInfo::FirstVirtualRegister); - if (!isPhysReg && !usedOutsideBlock) { - // DBG_VALUE complicates this: if the only refs of a register outside - // this block are DBG_VALUE, we can't keep the reg live just for that, - // as it will cause the reg to be spilled at the end of this block when - // it wouldn't have been otherwise. Nullify the DBG_VALUEs when that - // happens. - bool UsedByDebugValueOnly = false; + if (!isPhysReg && !usedOutsideBlock) for (MachineRegisterInfo::reg_iterator UI = MRI.reg_begin(MO.getReg()), UE = MRI.reg_end(); UI != UE; ++UI) // Two cases: @@ -710,26 +702,12 @@ // - used in the same block before it is defined (loop) if (UI->getParent() != &MBB || (MO.isDef() && UI.getOperand().isUse() && precedes(&*UI, MI))) { - if (UI->isDebugValue()) { - UsedByDebugValueOnly = true; - continue; - } - // A non-DBG_VALUE use means we can leave DBG_VALUE uses alone. UsedInMultipleBlocks.set(MO.getReg() - TargetRegisterInfo::FirstVirtualRegister); usedOutsideBlock = true; - UsedByDebugValueOnly = false; break; } - if (UsedByDebugValueOnly) - for (MachineRegisterInfo::reg_iterator UI = MRI.reg_begin(MO.getReg()), - UE = MRI.reg_end(); UI != UE; ++UI) - if (UI->isDebugValue() && - (UI->getParent() != &MBB || - (MO.isDef() && precedes(&*UI, MI)))) - UI.getOperand().setReg(0U); - } - + // Physical registers and those that are not live-out of the block // are killed/dead at their last use/def within this block. if (isPhysReg || !usedOutsideBlock) { From isanbard at gmail.com Mon Feb 15 18:58:03 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Feb 2010 00:58:03 -0000 Subject: [llvm-commits] [llvm] r96304 - /llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp Message-ID: <201002160058.o1G0w3Cd031553@zion.cs.uiuc.edu> Author: void Date: Mon Feb 15 18:58:02 2010 New Revision: 96304 URL: http://llvm.org/viewvc/llvm-project?rev=96304&view=rev Log: Apply patch from http://llvm.org/bugs/attachment.cgi?id=4136 now that PR5004 is finished. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp?rev=96304&r1=96303&r2=96304&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp Mon Feb 15 18:58:02 2010 @@ -522,7 +522,11 @@ JCE->emitInt64(((intptr_t)Jit.getPointerToGlobal(Personality))); } - JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4); + // LSDA encoding: This must match the encoding used in EmitEHFrame () + if (PointerSize == 4) + JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4); + else + JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8); JCE->emitULEB128Bytes(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4); } else { JCE->emitULEB128Bytes(1); From rafael.espindola at gmail.com Mon Feb 15 19:16:54 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 16 Feb 2010 01:16:54 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96305 - in /llvm-gcc-4.2/trunk/gcc: Makefile.in config/rs6000/llvm-rs6000.cpp config/rs6000/rs6000.h llvm-abi-default.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp Message-ID: <201002160116.o1G1GsN4032464@zion.cs.uiuc.edu> Author: rafael Date: Mon Feb 15 19:16:53 2010 New Revision: 96305 URL: http://llvm.org/viewvc/llvm-project?rev=96305&view=rev Log: Merge SVR4ABI and DefaultABI. 8 files changed, 134 insertions(+), 497 deletions(-) Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=96305&r1=96304&r2=96305&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/Makefile.in (original) +++ llvm-gcc-4.2/trunk/gcc/Makefile.in Mon Feb 15 19:16:53 2010 @@ -1141,7 +1141,7 @@ OBJS = $(OBJS-common) $(out_object_file) $(OBJS-archive) # LLVM LOCAL begin ifneq ($(LLVMOBJDIR),) -OBJS-common += llvm-backend.o llvm-convert.o llvm-types.o llvm-debug.o llvm-linker-hack.o llvm-abi-default.o llvm-abi-linux-ppc.o +OBJS-common += llvm-backend.o llvm-convert.o llvm-types.o llvm-debug.o llvm-linker-hack.o llvm-abi-default.o endif ifneq ($(LLVMOBJDIR),) Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=96305&r1=96304&r2=96305&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Mon Feb 15 19:16:53 2010 @@ -387,6 +387,118 @@ return false; } +static unsigned count_num_registers_uses(std::vector &ScalarElts) { + unsigned NumGPRs = 0; + for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { + if (NumGPRs >= 8) + break; + const Type *Ty = ScalarElts[i]; + if (const VectorType *VTy = dyn_cast(Ty)) { + abort(); + } else if (isa(Ty)) { + NumGPRs++; + } else if (Ty->isIntegerTy()) { + unsigned TypeSize = Ty->getPrimitiveSizeInBits(); + unsigned NumRegs = (TypeSize + 31) / 32; + + NumGPRs += NumRegs; + } else if (Ty->isVoidTy()) { + // Padding bytes that are not passed anywhere + ; + } else { + // Floating point scalar argument. + assert(Ty->isFloatingPointTy() && Ty->isPrimitiveType() && + "Expecting a floating point primitive type!"); + } + } + return NumGPRs < 8 ? NumGPRs : 8; +} + +/// _Complex arguments are never split, thus their two scalars are either +/// passed both in argument registers or both on the stack. Also _Complex +/// arguments are always passed in general purpose registers, never in +/// Floating-point registers or vector registers. +bool llvm_rs6000_try_pass_aggregate_custom(tree type, + std::vector &ScalarElts, + const CallingConv::ID &CC, + struct DefaultABIClient* C) { + if (!isSVR4ABI()) + return false; + + // Eight GPR's are availabe for parameter passing. + const unsigned NumArgRegs = 8; + unsigned NumGPR = count_num_registers_uses(ScalarElts); + const Type *Ty = ConvertType(type); + const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); + if (Ty->isSingleValueType()) { + if (Ty->isIntegerTy()) { + unsigned TypeSize = Ty->getPrimitiveSizeInBits(); + + // Determine how many general purpose registers are needed for the + // argument. + unsigned NumRegs = (TypeSize + 31) / 32; + + // Make sure argument registers are aligned. 64-bit arguments are put in + // a register pair which starts with an odd register number. + if (TypeSize == 64 && (NumGPR % 2) == 1) { + NumGPR++; + ScalarElts.push_back(Int32Ty); + C->HandlePad(Int32Ty); + } + + if (NumGPR > (NumArgRegs - NumRegs)) { + for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { + ScalarElts.push_back(Int32Ty); + C->HandlePad(Int32Ty); + } + } + } else if (!(Ty->isFloatingPointTy() || + isa(Ty) || + isa(Ty))) { + abort(); + } + + C->HandleScalarArgument(Ty, type); + ScalarElts.push_back(Ty); + return true; + } + if (TREE_CODE(type) == COMPLEX_TYPE) { + unsigned SrcSize = int_size_in_bytes(type); + unsigned NumRegs = (SrcSize + 3) / 4; + std::vector Elts; + + // This looks very strange, but matches the old code. + if (SrcSize == 8) { + // Make sure argument registers are aligned. 64-bit arguments are put in + // a register pair which starts with an odd register number. + if (NumGPR % 2 == 1) { + NumGPR++; + ScalarElts.push_back(Int32Ty); + C->HandlePad(Int32Ty); + } + } + + if (NumGPR > (NumArgRegs - NumRegs)) { + for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { + ScalarElts.push_back(Int32Ty); + C->HandlePad(Int32Ty); + } + } + for (unsigned int i = 0; i < NumRegs; ++i) { + Elts.push_back(Int32Ty); + } + const StructType *STy = StructType::get(getGlobalContext(), Elts, false); + for (unsigned int i = 0; i < NumRegs; ++i) { + C->EnterField(i, STy); + C->HandleScalarArgument(Int32Ty, 0); + ScalarElts.push_back(Int32Ty); + C->ExitField(); + } + return true; + } + return false; +} + /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed using the byval mechanism. */ bool llvm_rs6000_should_pass_aggregate_byval(tree TreeType, const Type *Ty) { Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h?rev=96305&r1=96304&r2=96305&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Mon Feb 15 19:16:53 2010 @@ -3488,6 +3488,15 @@ TargetIntrinsicLower(EXP, BUILTIN_CODE, DESTLOC, RESULT, DESTTY, OPS); #ifdef LLVM_ABI_H + +extern bool llvm_rs6000_try_pass_aggregate_custom(tree, + std::vector&, + const CallingConv::ID &, + struct DefaultABIClient*); + +#define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \ + llvm_rs6000_try_pass_aggregate_custom((T), (E), (CC), (C)) + extern bool llvm_rs6000_should_pass_aggregate_byval(tree, const Type *); #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp?rev=96305&r1=96304&r2=96305&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp Mon Feb 15 19:16:53 2010 @@ -92,6 +92,9 @@ C.HandleScalarArgument(Ty, type); ScalarElts.push_back(Ty); } + } else if (LLVM_TRY_PASS_AGGREGATE_CUSTOM(type, ScalarElts, + C.getCallingConv(), &C)) { + // Nothing to do. } else if (Ty->isSingleValueType()) { C.HandleScalarArgument(Ty, type); ScalarElts.push_back(Ty); Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=96305&r1=96304&r2=96305&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Feb 15 19:16:53 2010 @@ -254,6 +254,11 @@ return NULL; } +#ifndef LLVM_TRY_PASS_AGGREGATE_CUSTOM +#define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \ + false +#endif + // LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS - Return true if this vector // type should be passed as integer registers. Generally vectors which are // not part of the target architecture should do this. @@ -420,38 +425,5 @@ std::vector &ScalarElts); }; -// Similar to DefaultABI but for linux ppc 32 bits -class SVR4ABI{ - // Number of general purpose argument registers which have already been - // assigned. -protected: - DefaultABIClient &C; -public: - SVR4ABI(DefaultABIClient &c); - - bool isShadowReturn() const; - void HandleReturnType(tree type, tree fn, bool isBuiltin); - void HandleArgument(tree type, std::vector &ScalarElts, - Attributes *Attributes = NULL); - void HandleUnion(tree type, std::vector &ScalarElts); - void PassInIntegerRegisters(tree type, std::vector &ScalarElts, - unsigned origSize, bool DontCheckAlignment); - void PassInMixedRegisters(const Type *Ty, std::vector &OrigElts, - std::vector &ScalarElts); - -}; - -// Make sure the SVR4 ABI is used on 32-bit PowerPC Linux. -#if defined(POWERPC_LINUX) && (TARGET_64BIT == 0) -#define TheLLVMABI SVR4ABI -#endif - -/// TheLLVMABI - This can be defined by targets if they want total control over -/// ABI decisions. -/// -#ifndef TheLLVMABI -#define TheLLVMABI DefaultABI -#endif - #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=96305&r1=96304&r2=96305&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Feb 15 19:16:53 2010 @@ -622,7 +622,7 @@ // Rename and alloca'ify real arguments. FunctionPrologArgumentConversion Client(FnDecl, AI, Builder, CallingConv); - TheLLVMABI ABIConverter(Client); + DefaultABI ABIConverter(Client); // Handle the DECL_RESULT. ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)), FnDecl, @@ -2831,7 +2831,7 @@ FunctionCallArgumentConversion Client(CallOperands, FTy, DestLoc, CALL_EXPR_RETURN_SLOT_OPT(exp), Builder, CallingConvention); - TheLLVMABI ABIConverter(Client); + DefaultABI ABIConverter(Client); // Handle the result, including struct returns. ABIConverter.HandleReturnType(TREE_TYPE(exp), Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=96305&r1=96304&r2=96305&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Feb 15 19:16:53 2010 @@ -1047,7 +1047,7 @@ PATypeHolder RetTy(Type::getVoidTy(Context)); FunctionTypeConversion Client(RetTy, ArgTys, CallingConv, true /*K&R*/); - TheLLVMABI ABIConverter(Client); + DefaultABI ABIConverter(Client); #ifdef TARGET_ADJUST_LLVM_CC TARGET_ADJUST_LLVM_CC(CallingConv, type); @@ -1110,7 +1110,7 @@ std::vector ArgTypes; bool isVarArg = false; FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/); - TheLLVMABI ABIConverter(Client); + DefaultABI ABIConverter(Client); // Allow the target to set the CC for things like fastcall etc. #ifdef TARGET_ADJUST_LLVM_CC From dalej at apple.com Mon Feb 15 19:27:48 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Feb 2010 01:27:48 -0000 Subject: [llvm-commits] [llvm] r96307 - /llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Message-ID: <201002160127.o1G1Rmxg000605@zion.cs.uiuc.edu> Author: johannes Date: Mon Feb 15 19:27:47 2010 New Revision: 96307 URL: http://llvm.org/viewvc/llvm-project?rev=96307&view=rev Log: Reapply 96294; now that I've gotten around to looking at older buildbot messages, I see the failure predates this patch. Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=96307&r1=96306&r2=96307&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Mon Feb 15 19:27:47 2010 @@ -490,10 +490,12 @@ // If the virtual register is already available, just update the instruction // and return. if (unsigned PR = getVirt2PhysRegMapSlot(VirtReg)) { - MarkPhysRegRecentlyUsed(PR); // Already have this value available! MI->getOperand(OpNum).setReg(PR); // Assign the input register - if (!MI->isDebugValue()) + if (!MI->isDebugValue()) { + // Do not do these for DBG_VALUE as they can affect codegen. + MarkPhysRegRecentlyUsed(PR); // Already have this value available! getVirtRegLastUse(VirtReg) = std::make_pair(MI, OpNum); + } return MI; } @@ -694,7 +696,13 @@ bool usedOutsideBlock = isPhysReg ? false : UsedInMultipleBlocks.test(MO.getReg() - TargetRegisterInfo::FirstVirtualRegister); - if (!isPhysReg && !usedOutsideBlock) + if (!isPhysReg && !usedOutsideBlock) { + // DBG_VALUE complicates this: if the only refs of a register outside + // this block are DBG_VALUE, we can't keep the reg live just for that, + // as it will cause the reg to be spilled at the end of this block when + // it wouldn't have been otherwise. Nullify the DBG_VALUEs when that + // happens. + bool UsedByDebugValueOnly = false; for (MachineRegisterInfo::reg_iterator UI = MRI.reg_begin(MO.getReg()), UE = MRI.reg_end(); UI != UE; ++UI) // Two cases: @@ -702,12 +710,26 @@ // - used in the same block before it is defined (loop) if (UI->getParent() != &MBB || (MO.isDef() && UI.getOperand().isUse() && precedes(&*UI, MI))) { + if (UI->isDebugValue()) { + UsedByDebugValueOnly = true; + continue; + } + // A non-DBG_VALUE use means we can leave DBG_VALUE uses alone. UsedInMultipleBlocks.set(MO.getReg() - TargetRegisterInfo::FirstVirtualRegister); usedOutsideBlock = true; + UsedByDebugValueOnly = false; break; } - + if (UsedByDebugValueOnly) + for (MachineRegisterInfo::reg_iterator UI = MRI.reg_begin(MO.getReg()), + UE = MRI.reg_end(); UI != UE; ++UI) + if (UI->isDebugValue() && + (UI->getParent() != &MBB || + (MO.isDef() && precedes(&*UI, MI)))) + UI.getOperand().setReg(0U); + } + // Physical registers and those that are not live-out of the block // are killed/dead at their last use/def within this block. if (isPhysReg || !usedOutsideBlock) { From gohman at apple.com Mon Feb 15 19:42:53 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Feb 2010 01:42:53 -0000 Subject: [llvm-commits] [llvm] r96308 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/lsr-reuse-trunc.ll Message-ID: <201002160142.o1G1grCh001404@zion.cs.uiuc.edu> Author: djg Date: Mon Feb 15 19:42:53 2010 New Revision: 96308 URL: http://llvm.org/viewvc/llvm-project?rev=96308&view=rev Log: Split the main for-each-use loop again, this time for GenerateTruncates, as it also peeks at which registers are being used by other uses. This makes LSR less sensitive to use-list order. Added: llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96308&r1=96307&r2=96308&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Feb 15 19:42:53 2010 @@ -2427,7 +2427,7 @@ /// GenerateAllReuseFormulae - Generate formulae for each use. void LSRInstance::GenerateAllReuseFormulae() { - // This is split into two loops so that hasRegsUsedByUsesOtherThan + // This is split into multiple loops so that hasRegsUsedByUsesOtherThan // queries are more precise. for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) { LSRUse &LU = Uses[LUIdx]; @@ -2446,6 +2446,9 @@ GenerateICmpZeroScales(LU, LUIdx, LU.Formulae[i]); for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i) GenerateScales(LU, LUIdx, LU.Formulae[i]); + } + for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) { + LSRUse &LU = Uses[LUIdx]; for (size_t i = 0, f = LU.Formulae.size(); i != f; ++i) GenerateTruncates(LU, LUIdx, LU.Formulae[i]); } Added: llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll?rev=96308&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll (added) +++ llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll Mon Feb 15 19:42:53 2010 @@ -0,0 +1,59 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s + +; Full strength reduction wouldn't reduce register pressure, so LSR should +; stick with indexing here. + +; CHECK: movaps (%rsi,%rax,4), %xmm3 +; CHECK: movaps %xmm3, (%rdi,%rax,4) +; CHECK: addq $4, %rax +; CHECK: cmpl %eax, (%rdx) +; CHECK-NEXT: jg + +define void @vvfloorf(float* nocapture %y, float* nocapture %x, i32* nocapture %n) nounwind { +entry: + %0 = load i32* %n, align 4 + %1 = icmp sgt i32 %0, 0 + br i1 %1, label %bb, label %return + +bb: + %indvar = phi i64 [ %indvar.next, %bb ], [ 0, %entry ] + %tmp = shl i64 %indvar, 2 + %scevgep = getelementptr float* %y, i64 %tmp + %scevgep9 = bitcast float* %scevgep to <4 x float>* + %scevgep10 = getelementptr float* %x, i64 %tmp + %scevgep1011 = bitcast float* %scevgep10 to <4 x float>* + %2 = load <4 x float>* %scevgep1011, align 16 + %3 = bitcast <4 x float> %2 to <4 x i32> + %4 = and <4 x i32> %3, + %5 = bitcast <4 x i32> %4 to <4 x float> + %6 = and <4 x i32> %3, + %7 = tail call <4 x float> @llvm.x86.sse.cmp.ps(<4 x float> %5, <4 x float> , i8 5) nounwind + %tmp.i4 = bitcast <4 x float> %7 to <4 x i32> + %8 = xor <4 x i32> %tmp.i4, + %9 = and <4 x i32> %8, + %10 = or <4 x i32> %9, %6 + %11 = bitcast <4 x i32> %10 to <4 x float> + %12 = fadd <4 x float> %2, %11 + %13 = fsub <4 x float> %12, %11 + %14 = tail call <4 x float> @llvm.x86.sse.cmp.ps(<4 x float> %2, <4 x float> %13, i8 1) nounwind + %15 = bitcast <4 x float> %14 to <4 x i32> + %16 = tail call <4 x float> @llvm.x86.sse2.cvtdq2ps(<4 x i32> %15) nounwind readnone + %17 = fadd <4 x float> %13, %16 + %tmp.i = bitcast <4 x float> %17 to <4 x i32> + %18 = or <4 x i32> %tmp.i, %6 + %19 = bitcast <4 x i32> %18 to <4 x float> + store <4 x float> %19, <4 x float>* %scevgep9, align 16 + %tmp12 = add i64 %tmp, 4 + %tmp13 = trunc i64 %tmp12 to i32 + %20 = load i32* %n, align 4 + %21 = icmp sgt i32 %20, %tmp13 + %indvar.next = add i64 %indvar, 1 + br i1 %21, label %bb, label %return + +return: + ret void +} + +declare <4 x float> @llvm.x86.sse.cmp.ps(<4 x float>, <4 x float>, i8) nounwind readnone + +declare <4 x float> @llvm.x86.sse2.cvtdq2ps(<4 x i32>) nounwind readnone From rafael.espindola at gmail.com Mon Feb 15 19:50:18 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 16 Feb 2010 01:50:18 -0000 Subject: [llvm-commits] [llvm] r96312 - /llvm/trunk/lib/Target/PowerPC/PPCCallingConv.td Message-ID: <201002160150.o1G1oIhE001793@zion.cs.uiuc.edu> Author: rafael Date: Mon Feb 15 19:50:18 2010 New Revision: 96312 URL: http://llvm.org/viewvc/llvm-project?rev=96312&view=rev Log: Drop support for the InReg attribute on the ppc backend. This was used by llvm-gcc but has been replaced with pad argument which don't need any special backend support. Modified: llvm/trunk/lib/Target/PowerPC/PPCCallingConv.td Modified: llvm/trunk/lib/Target/PowerPC/PPCCallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCCallingConv.td?rev=96312&r1=96311&r2=96312&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCCallingConv.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCCallingConv.td Mon Feb 15 19:50:18 2010 @@ -66,28 +66,13 @@ // PowerPC System V Release 4 ABI //===----------------------------------------------------------------------===// -// _Complex arguments are never split, thus their two scalars are either -// passed both in argument registers or both on the stack. Also _Complex -// arguments are always passed in general purpose registers, never in -// Floating-point registers or vector registers. Arguments which should go -// on the stack are marked with the inreg parameter attribute. -// Giving inreg this target-dependent (and counter-intuitive) meaning -// simplifies things, because functions calls are not always coming from the -// frontend but are also created implicitly e.g. for libcalls. If inreg would -// actually mean that the argument is passed in a register, then all places -// which create function calls/function definitions implicitly would need to -// be aware of this fact and would need to mark arguments accordingly. With -// inreg meaning that the argument is passed on the stack, this is not an -// issue, except for calls which involve _Complex types. - def CC_PPC_SVR4_Common : CallingConv<[ // The ABI requires i64 to be passed in two adjacent registers with the first // register having an odd register number. CCIfType<[i32], CCIfSplit>>, // The first 8 integer arguments are passed in integer registers. - CCIfType<[i32], CCIf<"!ArgFlags.isInReg()", - CCAssignToReg<[R3, R4, R5, R6, R7, R8, R9, R10]>>>, + CCIfType<[i32], CCAssignToReg<[R3, R4, R5, R6, R7, R8, R9, R10]>>, // Make sure the i64 words from a long double are either both passed in // registers or both passed on the stack. From dalej at apple.com Mon Feb 15 19:57:29 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Feb 2010 01:57:29 -0000 Subject: [llvm-commits] [llvm] r96318 - /llvm/trunk/lib/CodeGen/PHIElimination.h Message-ID: <201002160157.o1G1vTbv002195@zion.cs.uiuc.edu> Author: johannes Date: Mon Feb 15 19:57:28 2010 New Revision: 96318 URL: http://llvm.org/viewvc/llvm-project?rev=96318&view=rev Log: Handle DBG_VALUE mixed with labels when doing PHI elimination. Before a DBG_VALUE could affect codegen. The solution here is imperfect and not final. Modified: llvm/trunk/lib/CodeGen/PHIElimination.h Modified: llvm/trunk/lib/CodeGen/PHIElimination.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=96318&r1=96317&r2=96318&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.h (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.h Mon Feb 15 19:57:28 2010 @@ -109,12 +109,29 @@ // SkipPHIsAndLabels - Copies need to be inserted after phi nodes and // also after any exception handling labels: in landing pads execution // starts at the label, so any copies placed before it won't be executed! + // We also deal with DBG_VALUEs, which are a bit tricky: + // PHI + // DBG_VALUE + // LABEL + // Here the DBG_VALUE needs to be skipped, and if it refers to a PHI it + // needs to be annulled or, better, moved to follow the label, as well. + // PHI + // DBG_VALUE + // no label + // Here it is not a good idea to skip the DBG_VALUE. + // FIXME: For now we skip and annul all DBG_VALUEs, maximally simple and + // maximally stupid. MachineBasicBlock::iterator SkipPHIsAndLabels(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) { // Rather than assuming that EH labels come before other kinds of labels, // just skip all labels. - while (I != MBB.end() && (I->isPHI() || I->isLabel())) + while (I != MBB.end() && + (I->isPHI() || I->isLabel() || I->isDebugValue())) { + if (I->isDebugValue() && I->getNumOperands()==3 && + I->getOperand(0).isReg()) + I->getOperand(0).setReg(0U); ++I; + } return I; } From nicholas at mxc.ca Mon Feb 15 20:00:28 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 15 Feb 2010 18:00:28 -0800 Subject: [llvm-commits] patch: moving unreachable elimination to codegenprep In-Reply-To: References: <4B68588F.7070906@mxc.ca> <4B6907EF.4050003@mxc.ca> Message-ID: <4B79FC3C.9020001@mxc.ca> Dan Gohman wrote: > > On 2 February 2010 21:21, Nick Lewycky wrote: >> >> Jakob, I'll make the tweaks to InlineCost that you proposed and post an >> updated patch with the results of a nightly test run. Realize that I'm >> expecting no visible performance difference at all since no code in the >> nightly test uses __builtin_unreachable(). > > There is code which uses things like "noreturn" and other > things which can lead to unreachable getting generated. > Offhand you may be right that these wouldn't be affected > though. This happens to be a very testable hypothesis :). A 'noreturn' function call turns into a call + unreachable. The call can't be eliminated, so this patch has no effect on that case, since it's not a branch to unreachable (it'd a branch to call). I want to emphasize that this patch is not nearly as scary as you seem to think it is. :-) > Would you mind compiling some tests with and without the > change, and diffing the .s files? I'd be interested in > learning what kinds of diffs, if any, appear. Done, asmchanges.diff attached. Original is - with my patch is + . I took TEST.llc.Makefile and modified it to keep the .s files, then did a run with and without the patch to see what happens to the output. Everything different was diff'd and all the differences that were irrelevant (timestamp, filename, anonymous namespace(!)) were removed. The remaining differences are a complete mystery to me -- I wonder whether two runs of llc even emit the same thing. :) > I'm concerned that artificially keeping the condition > instructions live will hamper the optimizer. Your benchmark > results are good, however it's not clear if that's just a > consequence of an absence of __builtin_unreachable or if > that actually says something about the impact of artificial > life on the optimizer. > > One comment on the patch itself: > > --- lib/Analysis/ScalarEvolution.cpp (revision 95201) > +++ lib/Analysis/ScalarEvolution.cpp (working copy) > > + // Ignore faux exits. > + for (unsigned i = 0; i != ExitingBlocks.size(); ++i) { > + if (isa(ExitingBlocks[i]->front())) { > + ExitingBlocks.erase(ExitingBlocks.begin() + i); > + --i; > + } > + } > > ExitingBlocks is an unsorted array. Instead of deleting blocks from > the middle of it, please swap the element to the end and pop_back(). Good point. Thanks! Updated patch attached. > Also, would it make sense to pull this code into the Loop(Base) class > itself? There is other code that looks at loop exists and probably > would need this. I'm not sure. This stuff is used to look at the CFG and I don't really want it to start lying lest we end up breaking domtree updates or violating SSA properties. It would make sense to revisit this if all users are doing things that are safe when ignoring dead exits. Nick -------------- next part -------------- A non-text attachment was scrubbed... Name: asmchanges.diff Type: text/x-diff Size: 296077 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/b8930385/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: preserve-unreachable4.patch Type: text/x-diff Size: 23802 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100215/b8930385/attachment-0001.bin From nicholas at mxc.ca Mon Feb 15 20:03:41 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 15 Feb 2010 18:03:41 -0800 Subject: [llvm-commits] patch: moving unreachable elimination to codegenprep In-Reply-To: <0437A6DB-4E24-4388-A133-1F654703FEBB@2pi.dk> References: <4B68588F.7070906@mxc.ca> <4B6907EF.4050003@mxc.ca> <0437A6DB-4E24-4388-A133-1F654703FEBB@2pi.dk> Message-ID: <4B79FCFD.8020705@mxc.ca> Jakob Stoklund Olesen wrote: > > On Feb 2, 2010, at 9:21 PM, Nick Lewycky wrote: > >> Jakob Stoklund Olesen wrote: >>> >>> On Feb 2, 2010, at 8:53 AM, Nick Lewycky wrote: >>> >>>> This is a resurrection of the patch first discussed back in October 2009 to change the way unreachable is handled to make it live in the IR for as long as possible. The goal is to implement http://nondot.org/sabre/LLVMNotes/BuiltinUnreachable.txt in time for the LLVM 2.7 freeze so that python can make use of it when they land unladen-swallow. >>> >>> Nick, I couldn't find that discussion in the archives. Do you have any pointers? >> >> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091012/089120.html > > Thanks, it looks like Dan and Chris have already covered it. > > [...] > >> Jakob, I'll make the tweaks to InlineCost that you proposed and post an updated patch with the results of a nightly test run. Realize that I'm expecting no visible performance difference at all since no code in the nightly test uses __builtin_unreachable(). > > Thanks. > > Your update to InlineCost looks fine to me, but undead instructions feeding into the condition are still counted. They are. I didn't see an efficient way to implement it, so I didn't. Given that this construct will be very rare, it shouldn't change much. I'll be happy to fix it if there's a real-world example that it breaks -- or if you see a good way to add it that doesn't double-count when two conditional branches both lead to the same unreachable-only block. > I would like this patch better if you would implement Chris' suggestion of DCE'ing unreachable blocks with conditions that are too gross for the optimizer. As it stands there can be arbitrarily complex instructions feeding into the condition. No. The optimizers can't make use of the chain of information that unladen-swallow is planning to add. The idea is that u-s will be pinned to the llvm 2.7 release, and can add their own passes to the mix. That's fine for many things, but useless if simplifycfg is deleting our instructions before we get to see them. Again, we have a concrete use case for this. Nick From rafael.espindola at gmail.com Mon Feb 15 20:20:49 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 16 Feb 2010 02:20:49 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96320 - /llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp Message-ID: <201002160220.o1G2Knbj003282@zion.cs.uiuc.edu> Author: rafael Date: Mon Feb 15 20:20:48 2010 New Revision: 96320 URL: http://llvm.org/viewvc/llvm-project?rev=96320&view=rev Log: Remove llvm-abi-linux-ppc.cpp. Missed that from the last commit. Removed: llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp Removed: llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp?rev=96319&view=auto ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-linux-ppc.cpp (removed) @@ -1,459 +0,0 @@ -#include "llvm-abi.h" - -SVR4ABI::SVR4ABI(DefaultABIClient &c) : C(c) {} - -bool SVR4ABI::isShadowReturn() const { return C.isShadowReturn(); } - -/// HandleReturnType - This is invoked by the target-independent code for the -/// return type. It potentially breaks down the argument and invokes methods -/// on the client that indicate how its pieces should be handled. This -/// handles things like returning structures via hidden parameters. -void SVR4ABI::HandleReturnType(tree type, tree fn, bool isBuiltin) { - unsigned Offset = 0; - const Type *Ty = ConvertType(type); - if (isa(Ty)) { - // Vector handling is weird on x86. In particular builtin and - // non-builtin function of the same return types can use different - // calling conventions. - tree ScalarType = LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR(type, isBuiltin); - if (ScalarType) - C.HandleAggregateResultAsScalar(ConvertType(ScalarType)); - else if (LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(type, isBuiltin)) - C.HandleScalarShadowResult(Ty->getPointerTo(), false); - else - C.HandleScalarResult(Ty); - } else if (Ty->isSingleValueType() || Ty->isVoidTy()) { - // Return scalar values normally. - C.HandleScalarResult(Ty); - } else if (doNotUseShadowReturn(type, fn, C.getCallingConv())) { - tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type); - if (SingleElt && TYPE_SIZE(SingleElt) && - TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST && - TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) == - TREE_INT_CST_LOW(TYPE_SIZE_UNIT(SingleElt))) { - C.HandleAggregateResultAsScalar(ConvertType(SingleElt)); - } else { - // Otherwise return as an integer value large enough to hold the entire - // aggregate. - if (const Type *AggrTy = LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(type, - C.getCallingConv())) - C.HandleAggregateResultAsAggregate(AggrTy); - else if (const Type* ScalarTy = - LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN(type, &Offset)) - C.HandleAggregateResultAsScalar(ScalarTy, Offset); - else { - assert(0 && "Unable to determine how to return this aggregate!"); - abort(); - } - } - } else { - // If the function is returning a struct or union, we pass the pointer to - // the struct as the first argument to the function. - - // FIXME: should return the hidden first argument for some targets - // (e.g. ELF i386). - C.HandleAggregateShadowResult(Ty->getPointerTo(), false); - } -} - -static unsigned count_num_registers_uses(std::vector &ScalarElts) { - unsigned NumGPRs = 0; - for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { - if (NumGPRs >= 8) - break; - const Type *Ty = ScalarElts[i]; - if (const VectorType *VTy = dyn_cast(Ty)) { - abort(); - } else if (isa(Ty)) { - NumGPRs++; - } else if (Ty->isIntegerTy()) { - unsigned TypeSize = Ty->getPrimitiveSizeInBits(); - unsigned NumRegs = (TypeSize + 31) / 32; - - NumGPRs += NumRegs; - } else if (Ty->isVoidTy()) { - // Padding bytes that are not passed anywhere - ; - } else { - // Floating point scalar argument. - assert(Ty->isFloatingPointTy() && Ty->isPrimitiveType() && - "Expecting a floating point primitive type!"); - } - } - return NumGPRs < 8 ? NumGPRs : 8; -} - -static bool isSVR4ABI() { -#if defined(POWERPC_LINUX) && (TARGET_64BIT == 0) - return true; -#else - return false; -#endif -} - -/// _Complex arguments are never split, thus their two scalars are either -/// passed both in argument registers or both on the stack. Also _Complex -/// arguments are always passed in general purpose registers, never in -/// Floating-point registers or vector registers. -static bool -llvm_ppc_try_pass_aggregate_custom(tree type, std::vector &ScalarElts, - const CallingConv::ID &CC, - struct DefaultABIClient* C) { - if (!isSVR4ABI()) - return false; - - // Eight GPR's are availabe for parameter passing. - const unsigned NumArgRegs = 8; - unsigned NumGPR = count_num_registers_uses(ScalarElts); - const Type *Ty = ConvertType(type); - const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); - if (Ty->isSingleValueType()) { - if (Ty->isIntegerTy()) { - unsigned TypeSize = Ty->getPrimitiveSizeInBits(); - - // Determine how many general purpose registers are needed for the - // argument. - unsigned NumRegs = (TypeSize + 31) / 32; - - // Make sure argument registers are aligned. 64-bit arguments are put in - // a register pair which starts with an odd register number. - if (TypeSize == 64 && (NumGPR % 2) == 1) { - NumGPR++; - ScalarElts.push_back(Int32Ty); - C->HandlePad(Int32Ty); - } - - if (NumGPR > (NumArgRegs - NumRegs)) { - for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { - ScalarElts.push_back(Int32Ty); - C->HandlePad(Int32Ty); - } - } - } else if (!(Ty->isFloatingPointTy() || - isa(Ty) || - isa(Ty))) { - abort(); - } - - C->HandleScalarArgument(Ty, type); - ScalarElts.push_back(Ty); - return true; - } - if (TREE_CODE(type) == COMPLEX_TYPE) { - unsigned SrcSize = int_size_in_bytes(type); - unsigned NumRegs = (SrcSize + 3) / 4; - std::vector Elts; - - // This looks very strange, but matches the old code. - if (SrcSize == 8) { - // Make sure argument registers are aligned. 64-bit arguments are put in - // a register pair which starts with an odd register number. - if (NumGPR % 2 == 1) { - NumGPR++; - ScalarElts.push_back(Int32Ty); - C->HandlePad(Int32Ty); - } - } - - if (NumGPR > (NumArgRegs - NumRegs)) { - for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) { - ScalarElts.push_back(Int32Ty); - C->HandlePad(Int32Ty); - } - } - for (unsigned int i = 0; i < NumRegs; ++i) { - Elts.push_back(Int32Ty); - } - const StructType *STy = StructType::get(getGlobalContext(), Elts, false); - for (unsigned int i = 0; i < NumRegs; ++i) { - C->EnterField(i, STy); - C->HandleScalarArgument(Int32Ty, 0); - ScalarElts.push_back(Int32Ty); - C->ExitField(); - } - return true; - } - return false; -} - -/// HandleArgument - This is invoked by the target-independent code for each -/// argument type passed into the function. It potentially breaks down the -/// argument and invokes methods on the client that indicate how its pieces -/// should be handled. This handles things like decimating structures into -/// their fields. -void SVR4ABI::HandleArgument(tree type, std::vector &ScalarElts, - Attributes *Attributes) { - unsigned Size = 0; - bool DontCheckAlignment = false; - const Type *Ty = ConvertType(type); - // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do - // not include variable sized fields here. - std::vector Elts; - if (Ty->isVoidTy()) { - // Handle void explicitly as an opaque type. - const Type *OpTy = OpaqueType::get(getGlobalContext()); - C.HandleScalarArgument(OpTy, type); - ScalarElts.push_back(OpTy); - } else if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - const Type *PtrTy = Ty->getPointerTo(); - C.HandleByInvisibleReferenceArgument(PtrTy, type); - ScalarElts.push_back(PtrTy); - } else if (isa(Ty)) { - if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) { - PassInIntegerRegisters(type, ScalarElts, 0, false); - } else if (LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(type)) { - C.HandleByValArgument(Ty, type); - if (Attributes) { - *Attributes |= Attribute::ByVal; - *Attributes |= - Attribute::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); - } - } else { - C.HandleScalarArgument(Ty, type); - ScalarElts.push_back(Ty); - } - } else if (llvm_ppc_try_pass_aggregate_custom(type, ScalarElts, C.getCallingConv(), &C)) { - // Nothing to do. - } else if (Ty->isSingleValueType()) { - C.HandleScalarArgument(Ty, type); - ScalarElts.push_back(Ty); - } else if (LLVM_SHOULD_PASS_AGGREGATE_AS_FCA(type, Ty)) { - C.HandleFCAArgument(Ty, type); - } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, - C.getCallingConv(), - Elts)) { - if (!LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Elts, ScalarElts, - C.isShadowReturn(), - C.getCallingConv())) - PassInMixedRegisters(Ty, Elts, ScalarElts); - else { - C.HandleByValArgument(Ty, type); - if (Attributes) { - *Attributes |= Attribute::ByVal; - *Attributes |= - Attribute::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); - } - } - } else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) { - C.HandleByValArgument(Ty, type); - if (Attributes) { - *Attributes |= Attribute::ByVal; - *Attributes |= - Attribute::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); - } - } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type, &Size, - &DontCheckAlignment)) { - PassInIntegerRegisters(type, ScalarElts, Size, DontCheckAlignment); - } else if (isZeroSizedStructOrUnion(type)) { - // Zero sized struct or union, just drop it! - ; - } else if (TREE_CODE(type) == RECORD_TYPE) { - for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) - if (TREE_CODE(Field) == FIELD_DECL) { - const tree Ftype = getDeclaredType(Field); - const Type *FTy = ConvertType(Ftype); - unsigned FNo = GET_LLVM_FIELD_INDEX(Field); - assert(FNo != ~0U && "Case not handled yet!"); - - // Currently, a bvyal type inside a non-byval struct is a zero-length - // object inside a bigger object on x86-64. This type should be - // skipped (but only when it is inside a bigger object). - // (We know there currently are no other such cases active because - // they would hit the assert in FunctionPrologArgumentConversion:: - // HandleByValArgument.) - if (!LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(Ftype, FTy)) { - C.EnterField(FNo, Ty); - HandleArgument(getDeclaredType(Field), ScalarElts); - C.ExitField(); - } - } - } else if (TREE_CODE(type) == COMPLEX_TYPE) { - C.EnterField(0, Ty); - HandleArgument(TREE_TYPE(type), ScalarElts); - C.ExitField(); - C.EnterField(1, Ty); - HandleArgument(TREE_TYPE(type), ScalarElts); - C.ExitField(); - } else if ((TREE_CODE(type) == UNION_TYPE) || - (TREE_CODE(type) == QUAL_UNION_TYPE)) { - HandleUnion(type, ScalarElts); - } else if (TREE_CODE(type) == ARRAY_TYPE) { - const ArrayType *ATy = cast(Ty); - for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) { - C.EnterField(i, Ty); - HandleArgument(TREE_TYPE(type), ScalarElts); - C.ExitField(); - } - } else { - assert(0 && "unknown aggregate type!"); - abort(); - } -} - -/// HandleUnion - Handle a UNION_TYPE or QUAL_UNION_TYPE tree. -void SVR4ABI::HandleUnion(tree type, std::vector &ScalarElts) { - if (TYPE_TRANSPARENT_UNION(type)) { - tree Field = TYPE_FIELDS(type); - assert(Field && "Transparent union must have some elements!"); - while (TREE_CODE(Field) != FIELD_DECL) { - Field = TREE_CHAIN(Field); - assert(Field && "Transparent union must have some elements!"); - } - - HandleArgument(TREE_TYPE(Field), ScalarElts); - } else { - // Unions pass the largest element. - unsigned MaxSize = 0; - tree MaxElt = 0; - for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { - if (TREE_CODE(Field) == FIELD_DECL) { - // Skip fields that are known not to be present. - if (TREE_CODE(type) == QUAL_UNION_TYPE && - integer_zerop(DECL_QUALIFIER(Field))) - continue; - - tree SizeTree = TYPE_SIZE(TREE_TYPE(Field)); - unsigned Size = ((unsigned)TREE_INT_CST_LOW(SizeTree)+7)/8; - if (Size > MaxSize) { - MaxSize = Size; - MaxElt = Field; - } - - // Skip remaining fields if this one is known to be present. - if (TREE_CODE(type) == QUAL_UNION_TYPE && - integer_onep(DECL_QUALIFIER(Field))) - break; - } - } - - if (MaxElt) - HandleArgument(TREE_TYPE(MaxElt), ScalarElts); - } -} - -/// PassInIntegerRegisters - Given an aggregate value that should be passed in -/// integer registers, convert it to a structure containing ints and pass all -/// of the struct elements in. If Size is set we pass only that many bytes. -void SVR4ABI::PassInIntegerRegisters(tree type, - std::vector &ScalarElts, - unsigned origSize, - bool DontCheckAlignment) { - unsigned Size; - if (origSize) - Size = origSize; - else - Size = TREE_INT_CST_LOW(TYPE_SIZE(type))/8; - - // FIXME: We should preserve all aggregate value alignment information. - // Work around to preserve some aggregate value alignment information: - // don't bitcast aggregate value to Int64 if its alignment is different - // from Int64 alignment. ARM backend needs this. - unsigned Align = TYPE_ALIGN(type)/8; - unsigned Int64Align = - getTargetData().getABITypeAlignment(Type::getInt64Ty(getGlobalContext())); - bool UseInt64 = (DontCheckAlignment || Align >= Int64Align); - - unsigned ElementSize = UseInt64 ? 8:4; - unsigned ArraySize = Size / ElementSize; - - // Put as much of the aggregate as possible into an array. - const Type *ATy = NULL; - const Type *ArrayElementType = NULL; - if (ArraySize) { - Size = Size % ElementSize; - ArrayElementType = (UseInt64 ? - Type::getInt64Ty(getGlobalContext()) : - Type::getInt32Ty(getGlobalContext())); - ATy = ArrayType::get(ArrayElementType, ArraySize); - } - - // Pass any leftover bytes as a separate element following the array. - unsigned LastEltRealSize = 0; - const llvm::Type *LastEltTy = 0; - if (Size > 4) { - LastEltTy = Type::getInt64Ty(getGlobalContext()); - } else if (Size > 2) { - LastEltTy = Type::getInt32Ty(getGlobalContext()); - } else if (Size > 1) { - LastEltTy = Type::getInt16Ty(getGlobalContext()); - } else if (Size > 0) { - LastEltTy = Type::getInt8Ty(getGlobalContext()); - } - if (LastEltTy) { - if (Size != getTargetData().getTypeAllocSize(LastEltTy)) - LastEltRealSize = Size; - } - - std::vector Elts; - if (ATy) - Elts.push_back(ATy); - if (LastEltTy) - Elts.push_back(LastEltTy); - const StructType *STy = StructType::get(getGlobalContext(), Elts, false); - - unsigned i = 0; - if (ArraySize) { - C.EnterField(0, STy); - for (unsigned j = 0; j < ArraySize; ++j) { - C.EnterField(j, ATy); - C.HandleScalarArgument(ArrayElementType, 0); - ScalarElts.push_back(ArrayElementType); - C.ExitField(); - } - C.ExitField(); - ++i; - } - if (LastEltTy) { - C.EnterField(i, STy); - C.HandleScalarArgument(LastEltTy, 0, LastEltRealSize); - ScalarElts.push_back(LastEltTy); - C.ExitField(); - } -} - -/// PassInMixedRegisters - Given an aggregate value that should be passed in -/// mixed integer, floating point, and vector registers, convert it to a -/// structure containing the specified struct elements in. -void SVR4ABI::PassInMixedRegisters(const Type *Ty, - std::vector &OrigElts, - std::vector &ScalarElts) { - // We use VoidTy in OrigElts to mean "this is a word in the aggregate - // that occupies storage but has no useful information, and is not passed - // anywhere". Happens on x86-64. - std::vector Elts(OrigElts); - const Type* wordType = getTargetData().getPointerSize() == 4 ? - Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext()); - for (unsigned i=0, e=Elts.size(); i!=e; ++i) - if (OrigElts[i]->isVoidTy()) - Elts[i] = wordType; - - const StructType *STy = StructType::get(getGlobalContext(), Elts, false); - - unsigned Size = getTargetData().getTypeAllocSize(STy); - const StructType *InSTy = dyn_cast(Ty); - unsigned InSize = 0; - // If Ty and STy size does not match then last element is accessing - // extra bits. - unsigned LastEltSizeDiff = 0; - if (InSTy) { - InSize = getTargetData().getTypeAllocSize(InSTy); - if (InSize < Size) { - unsigned N = STy->getNumElements(); - const llvm::Type *LastEltTy = STy->getElementType(N-1); - if (LastEltTy->isIntegerTy()) - LastEltSizeDiff = - getTargetData().getTypeAllocSize(LastEltTy) - (Size - InSize); - } - } - for (unsigned i = 0, e = Elts.size(); i != e; ++i) { - if (!OrigElts[i]->isVoidTy()) { - C.EnterField(i, STy); - unsigned RealSize = 0; - if (LastEltSizeDiff && i == (e - 1)) - RealSize = LastEltSizeDiff; - C.HandleScalarArgument(Elts[i], 0, RealSize); - ScalarElts.push_back(Elts[i]); - C.ExitField(); - } - } -} From sanjiv.gupta at microchip.com Mon Feb 15 21:41:07 2010 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 16 Feb 2010 03:41:07 -0000 Subject: [llvm-commits] [llvm] r96322 - in /llvm/trunk/lib/Target/PIC16: AsmPrinter/PIC16AsmPrinter.cpp PIC16ABINames.h PIC16TargetObjectFile.cpp PIC16TargetObjectFile.h Message-ID: <201002160341.o1G3f7ll007064@zion.cs.uiuc.edu> Author: sgupta Date: Mon Feb 15 21:41:07 2010 New Revision: 96322 URL: http://llvm.org/viewvc/llvm-project?rev=96322&view=rev Log: The code section for an ISR has a specific address. Currently, whether a function is ISR or not is encoded in the section attribute for that function. Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/PIC16ABINames.h llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=96322&r1=96321&r2=96322&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Mon Feb 15 21:41:07 2010 @@ -106,8 +106,9 @@ DbgInfo.BeginFunction(MF); // Now emit the instructions of function in its code section. - const MCSection *fCodeSection - = getObjFileLowering().SectionForCode(CurrentFnSym->getName()); + const MCSection *fCodeSection = + getObjFileLowering().SectionForCode(CurrentFnSym->getName(), + PAN::isISR(F->getSection())); // Start the Code Section. O << "\n"; Modified: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ABINames.h?rev=96322&r1=96321&r2=96322&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ABINames.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ABINames.h Mon Feb 15 21:41:07 2010 @@ -325,6 +325,19 @@ return o.str(); } + + // Return true if the current function is an ISR + inline static bool isISR(const std::string SectName) { + if (SectName.find("interrupt") != std::string::npos) + return true; + + return false; + } + + // Return the address for ISR starts in rom. + inline static std::string getISRAddr(void) { + return "0x4"; + } }; // class PAN. } // end namespace llvm; Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp?rev=96322&r1=96321&r2=96322&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.cpp Mon Feb 15 21:41:07 2010 @@ -315,8 +315,12 @@ // Interface used by AsmPrinter to get a code section for a function. const PIC16Section * -PIC16TargetObjectFile::SectionForCode(const std::string &FnName) const { +PIC16TargetObjectFile::SectionForCode(const std::string &FnName, + bool isISR) const { const std::string &sec_name = PAN::getCodeSectionName(FnName); + // If it is ISR, its code section starts at a specific address. + if (isISR) + return getPIC16Section(sec_name, CODE, PAN::getISRAddr()); return getPIC16Section(sec_name, CODE); } Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h?rev=96322&r1=96321&r2=96322&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetObjectFile.h Mon Feb 15 21:41:07 2010 @@ -137,7 +137,8 @@ /// Return a code section for a function. - const PIC16Section *SectionForCode (const std::string &FnName) const; + const PIC16Section *SectionForCode (const std::string &FnName, + bool isISR) const; /// Return a frame section for a function. const PIC16Section *SectionForFrame (const std::string &FnName) const; From idadesub at users.sourceforge.net Mon Feb 15 21:45:17 2010 From: idadesub at users.sourceforge.net (Erick Tryzelaar) Date: Tue, 16 Feb 2010 03:45:17 -0000 Subject: [llvm-commits] [llvm] r96323 - in /llvm/trunk/bindings/ocaml/llvm: llvm.mli llvm_ocaml.c Message-ID: <201002160345.o1G3jIVr007255@zion.cs.uiuc.edu> Author: erickt Date: Mon Feb 15 21:45:17 2010 New Revision: 96323 URL: http://llvm.org/viewvc/llvm-project?rev=96323&view=rev Log: Fix some ocaml documentation Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=96323&r1=96322&r2=96323&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Mon Feb 15 21:45:17 2010 @@ -1420,13 +1420,13 @@ = "llvm_build_aggregate_ret" (** [build_br bb b] creates a - [b %bb] + [br %bb] instruction at the position specified by the instruction builder [b]. See the method [llvm::LLVMBuilder::CreateBr]. *) external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br" (** [build_cond_br cond tbb fbb b] creates a - [b %cond, %tbb, %fbb] + [br %cond, %tbb, %fbb] instruction at the position specified by the instruction builder [b]. See the method [llvm::LLVMBuilder::CreateCondBr]. *) external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder -> @@ -1476,7 +1476,7 @@ external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue = "llvm_build_add" -(** [build_nswadd x y name b] creates a +(** [build_nsw_add x y name b] creates a [%name = nsw add %x, %y] instruction at the position specified by the instruction builder [b]. See the method [llvm::LLVMBuilder::CreateNSWAdd]. *) Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=96323&r1=96322&r2=96323&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Mon Feb 15 21:45:17 2010 @@ -1031,8 +1031,8 @@ return LLVMBuildSwitch(Builder_val(B), Of, Else, Int_val(EstimatedCount)); } -CAMLprim value llvm_add_case(LLVMValueRef Switch, - LLVMValueRef OnVal, +/* llvalue -> llvalue -> llbasicblock -> unit */ +CAMLprim value llvm_add_case(LLVMValueRef Switch, LLVMValueRef OnVal, LLVMBasicBlockRef Dest) { LLVMAddCase(Switch, OnVal, Dest); return Val_unit; From idadesub at users.sourceforge.net Mon Feb 15 21:45:23 2010 From: idadesub at users.sourceforge.net (Erick Tryzelaar) Date: Tue, 16 Feb 2010 03:45:23 -0000 Subject: [llvm-commits] [llvm] r96324 - /llvm/trunk/include/llvm-c/Core.h Message-ID: <201002160345.o1G3jNT6007271@zion.cs.uiuc.edu> Author: erickt Date: Mon Feb 15 21:45:23 2010 New Revision: 96324 URL: http://llvm.org/viewvc/llvm-project?rev=96324&view=rev Log: Fix a typo in an LLVMOpcode enum. LLVMTrunk -> LLVMTrunc. Modified: llvm/trunk/include/llvm-c/Core.h Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=96324&r1=96323&r2=96324&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Mon Feb 15 21:45:23 2010 @@ -161,7 +161,7 @@ LLVMGetElementPtr = 29, /* Cast Operators */ - LLVMTrunk = 30, + LLVMTrunc = 30, LLVMZExt = 31, LLVMSExt = 32, LLVMFPToUI = 33, From sabre at nondot.org Mon Feb 15 23:03:18 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 05:03:18 -0000 Subject: [llvm-commits] [llvm] r96330 - in /llvm/trunk: lib/Target/X86/X86MCCodeEmitter.cpp test/MC/AsmParser/X86/x86_64-new-encoder.s Message-ID: <201002160503.o1G53IrG010767@zion.cs.uiuc.edu> Author: lattner Date: Mon Feb 15 23:03:17 2010 New Revision: 96330 URL: http://llvm.org/viewvc/llvm-project?rev=96330&view=rev Log: make pcrel immediate values relative to the start of the field, not the end of the field, fixing rdar://7651978 Modified: llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s Modified: llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp?rev=96330&r1=96329&r2=96330&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp Mon Feb 15 23:03:17 2010 @@ -153,14 +153,25 @@ // If this is a simple integer displacement that doesn't require a relocation, // emit it now. if (DispOp.isImm()) { + // FIXME: is this right for pc-rel encoding?? Probably need to emit this as + // a fixup if so. EmitConstant(DispOp.getImm()+ImmOffset, Size, CurByte, OS); return; } // If we have an immoffset, add it to the expression. const MCExpr *Expr = DispOp.getExpr(); + + // If the fixup is pc-relative, we need to bias the value to be relative to + // the start of the field, not the end of the field. + if (FixupKind == MCFixupKind(X86::reloc_pcrel_4byte) || + FixupKind == MCFixupKind(X86::reloc_riprel_4byte)) + ImmOffset -= 4; + if (FixupKind == MCFixupKind(X86::reloc_pcrel_1byte)) + ImmOffset -= 1; + if (ImmOffset) - Expr = MCBinaryExpr::CreateAdd(Expr,MCConstantExpr::Create(ImmOffset, Ctx), + Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(ImmOffset, Ctx), Ctx); // Emit a symbolic constant as a fixup and 4 zeros. @@ -192,6 +203,7 @@ // the size of the immediate field. If we have this case, add it into the // expression to emit. int ImmSize = X86II::hasImm(TSFlags) ? X86II::getSizeOfImm(TSFlags) : 0; + EmitImmediate(Disp, 4, MCFixupKind(X86::reloc_riprel_4byte), CurByte, OS, Fixups, -ImmSize); return; @@ -616,8 +628,6 @@ // If there is a remaining operand, it must be a trailing immediate. Emit it // according to the right size for the instruction. - // FIXME: This should pass in whether the value is pc relative or not. This - // information should be aquired from TSFlags as well. if (CurOp != NumOps) EmitImmediate(MI.getOperand(CurOp++), X86II::getSizeOfImm(TSFlags), getImmFixupKind(TSFlags), Modified: llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s?rev=96330&r1=96329&r2=96330&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s (original) +++ llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s Mon Feb 15 23:03:17 2010 @@ -3,24 +3,24 @@ movl foo(%rip), %eax // CHECK: movl foo(%rip), %eax // CHECK: encoding: [0x8b,0x05,A,A,A,A] -// CHECK: fixup A - offset: 2, value: foo, kind: reloc_riprel_4byte +// CHECK: fixup A - offset: 2, value: foo-4, kind: reloc_riprel_4byte movb $12, foo(%rip) // CHECK: movb $12, foo(%rip) // CHECK: encoding: [0xc6,0x05,A,A,A,A,0x0c] -// CHECK: fixup A - offset: 2, value: foo-1, kind: reloc_riprel_4byte +// CHECK: fixup A - offset: 2, value: foo-5, kind: reloc_riprel_4byte movw $12, foo(%rip) // CHECK: movw $12, foo(%rip) // CHECK: encoding: [0x66,0xc7,0x05,A,A,A,A,0x0c,0x00] -// CHECK: fixup A - offset: 3, value: foo-2, kind: reloc_riprel_4byte +// CHECK: fixup A - offset: 3, value: foo-6, kind: reloc_riprel_4byte movl $12, foo(%rip) // CHECK: movl $12, foo(%rip) // CHECK: encoding: [0xc7,0x05,A,A,A,A,0x0c,0x00,0x00,0x00] -// CHECK: fixup A - offset: 2, value: foo-4, kind: reloc_riprel_4byte +// CHECK: fixup A - offset: 2, value: foo-8, kind: reloc_riprel_4byte movq $12, foo(%rip) // CHECK: movq $12, foo(%rip) // CHECK: encoding: [0x48,0xc7,0x05,A,A,A,A,0x0c,0x00,0x00,0x00] -// CHECK: fixup A - offset: 3, value: foo-4, kind: reloc_riprel_4byte +// CHECK: fixup A - offset: 3, value: foo-8, kind: reloc_riprel_4byte From sabre at nondot.org Tue Feb 16 00:11:00 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 06:11:00 -0000 Subject: [llvm-commits] [llvm] r96331 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/CodeGenDAGPatterns.h utils/TableGen/DAGISelEmitter.cpp utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002160611.o1G6B6Wo014194@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 00:10:58 2010 New Revision: 96331 URL: http://llvm.org/viewvc/llvm-project?rev=96331&view=rev Log: add support for the new isel matcher to generate (isprofitable|islegal)tofold checks. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96331&r1=96330&r2=96331&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Tue Feb 16 00:10:58 2010 @@ -202,7 +202,9 @@ OPC_CheckValueType, OPC_CheckComplexPat, OPC_CheckAndImm1, OPC_CheckAndImm2, OPC_CheckAndImm4, OPC_CheckAndImm8, - OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8 + OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8, + OPC_IsProfitableToFold, + OPC_IsLegalToFold }; struct MatchScope { @@ -379,6 +381,19 @@ case OPC_CheckOrImm8: if (CheckOrImmediate(N, GetInt8(MatcherTable, MatcherIndex))) break; continue; + + case OPC_IsProfitableToFold: + assert(!NodeStack.size() == 1 && "No parent node"); + if (!IsProfitableToFold(N, NodeStack[NodeStack.size()-2].getNode(), + NodeToMatch)) + break; + continue; + case OPC_IsLegalToFold: + assert(!NodeStack.size() == 1 && "No parent node"); + if (!IsLegalToFold(N, NodeStack[NodeStack.size()-2].getNode(), + NodeToMatch)) + break; + continue; } // If the code reached this point, then the match failed pop out to the next Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=96331&r1=96330&r2=96331&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Tue Feb 16 00:10:58 2010 @@ -216,6 +216,13 @@ void setChild(unsigned i, TreePatternNode *N) { Children[i] = N; } + + /// hasChild - Return true if N is any of our children. + bool hasChild(const TreePatternNode *N) const { + for (unsigned i = 0, e = Children.size(); i != e; ++i) + if (Children[i] == N) return true; + return false; + } const std::vector &getPredicateFns() const {return PredicateFns;} void clearPredicateFns() { PredicateFns.clear(); } Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96331&r1=96330&r2=96331&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 00:10:58 2010 @@ -586,6 +586,8 @@ // / [YY] // | ^ // [XX]-------| + + // We know we need the check if N's parent is not the root. bool NeedCheck = P != Pattern; if (!NeedCheck) { const SDNodeInfo &PInfo = CGP.getSDNodeInfo(P->getOperator()); Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96331&r1=96330&r2=96331&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Tue Feb 16 00:10:58 2010 @@ -106,3 +106,13 @@ printChild(OS, indent); } +void CheckProfitableToFoldMatcherNode::print(raw_ostream &OS, + unsigned indent) const { + OS.indent(indent) << "CheckProfitableToFold\n"; + printChild(OS, indent); +} + +void CheckLegalToFoldMatcherNode::print(raw_ostream &OS, unsigned indent) const{ + OS.indent(indent) << "CheckLegalToFold\n"; + printChild(OS, indent); +} Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96331&r1=96330&r2=96331&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Tue Feb 16 00:10:58 2010 @@ -48,7 +48,9 @@ CheckValueType, CheckComplexPat, CheckAndImm, - CheckOrImm + CheckOrImm, + CheckProfitableToFold, + CheckLegalToFold }; const KindTy Kind; @@ -355,8 +357,34 @@ virtual void print(raw_ostream &OS, unsigned indent = 0) const; }; + +/// CheckProfitableToFoldMatcherNode - This checks to see if the current node is +/// worthwhile to try to fold into a large pattern. +class CheckProfitableToFoldMatcherNode : public MatcherNodeWithChild { +public: + CheckProfitableToFoldMatcherNode() + : MatcherNodeWithChild(CheckProfitableToFold) {} + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckProfitableToFold; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// CheckLegalToFoldMatcherNode - This checks to see if the current node is +/// legal to try to fold into a large pattern. +class CheckLegalToFoldMatcherNode : public MatcherNodeWithChild { +public: + CheckLegalToFoldMatcherNode() + : MatcherNodeWithChild(CheckLegalToFold) {} + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckLegalToFold; + } + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; } // end namespace llvm #endif Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96331&r1=96330&r2=96331&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Tue Feb 16 00:10:58 2010 @@ -151,6 +151,12 @@ OS << "OPC_CheckOrImm" << ClassifyInt(Val) << ", "; return EmitInt(Val, OS)+1; } + case MatcherNode::CheckProfitableToFold: + OS << "OPC_IsProfitableToFold,\n"; + return 1; + case MatcherNode::CheckLegalToFold: + OS << "OPC_IsLegalToFold,\n"; + return 1; } assert(0 && "Unreachable"); return 0; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96331&r1=96330&r2=96331&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 00:10:58 2010 @@ -189,18 +189,61 @@ if (N->NodeHasProperty(SDNPHasChain, CGP)) OpNo = 1; - if (N->TreeHasProperty(SDNPHasChain, CGP)) { - // FIXME: Handle Chains with multiple uses etc. - // [ld] - // ^ ^ - // | | - // / \--- - // / [YY] - // | ^ - // [XX]-------| + // If this node is not the root and the subtree underneath it produces a + // chain, then the result of matching the node is also produce a chain. + // Beyond that, this means that we're also folding (at least) the root node + // into the node that produce the chain (for example, matching + // "(add reg, (load ptr))" as a add_with_memory on X86). This is problematic, + // if the 'reg' node also uses the load (say, its chain). Graphically: + // + // [LD] + // ^ ^ + // | \ DAG's like cheese. + // / | + // / [YY] + // | ^ + // [XX]--/ + // + // It would be invalid to fold XX and LD. In this case, folding the two + // nodes together would induce a cycle in the DAG, making it a cyclic DAG (!). + // To prevent this, we emit a dynamic check for legality before allowing this + // to be folded. + // + const TreePatternNode *Root = Pattern.getSrcPattern(); + if (N != Root && // Not the root of the pattern. + N->TreeHasProperty(SDNPHasChain, CGP)) { // Has a chain somewhere in tree. + + AddMatcherNode(new CheckProfitableToFoldMatcherNode()); + + // If this non-root node produces a chain, we may need to emit a validity + // check. + if (OpNo != 0) { + // If there is a node between the root and this node, then we definitely + // need to emit the check. + bool NeedCheck = !Root->hasChild(N); + + // If it *is* an immediate child of the root, we can still need a check if + // the root SDNode has multiple inputs. For us, this means that it is an + // intrinsic, has multiple operands, or has other inputs like chain or + // flag). + if (!NeedCheck) { + const SDNodeInfo &PInfo = CGP.getSDNodeInfo(Root->getOperator()); + NeedCheck = + Root->getOperator() == CGP.get_intrinsic_void_sdnode() || + Root->getOperator() == CGP.get_intrinsic_w_chain_sdnode() || + Root->getOperator() == CGP.get_intrinsic_wo_chain_sdnode() || + PInfo.getNumOperands() > 1 || + PInfo.hasProperty(SDNPHasChain) || + PInfo.hasProperty(SDNPInFlag) || + PInfo.hasProperty(SDNPOptInFlag); + } + + if (NeedCheck) + AddMatcherNode(new CheckLegalToFoldMatcherNode()); + } } - // FIXME: Handle Flags & .hasOneUse() + // FIXME: Handle EmittedUseCheck & Flags & .hasOneUse() for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { // Get the code suitable for matching this child. Move to the child, check From sabre at nondot.org Tue Feb 16 00:14:28 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 06:14:28 -0000 Subject: [llvm-commits] [llvm] r96332 - /llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002160614.o1G6ET0P014358@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 00:14:22 2010 New Revision: 96332 URL: http://llvm.org/viewvc/llvm-project?rev=96332&view=rev Log: remove dead code. This is never generated for any targets in mainline. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96332&r1=96331&r2=96332&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 00:14:22 2010 @@ -624,21 +624,6 @@ } } - // Don't fold any node which reads or writes a flag and has multiple uses. - // FIXME: We really need to separate the concepts of flag and "glue". Those - // real flag results, e.g. X86CMP output, can have multiple uses. - // FIXME: If the optional incoming flag does not exist. Then it is ok to - // fold it. - if (!isRoot && - (N->TreeHasProperty(SDNPInFlag, CGP) || - N->TreeHasProperty(SDNPOptInFlag, CGP) || - N->TreeHasProperty(SDNPOutFlag, CGP))) { - if (!EmittedUseCheck) { - // Multiple uses of actual result? - emitCheck(getValueName(RootName) + ".hasOneUse()"); - } - } - // If there are node predicates for this, emit the calls. for (unsigned i = 0, e = N->getPredicateFns().size(); i != e; ++i) emitCheck(N->getPredicateFns()[i] + "(" + getNodeName(RootName) + ")"); From sabre at nondot.org Tue Feb 16 00:15:00 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 06:15:00 -0000 Subject: [llvm-commits] [llvm] r96333 - in /llvm/trunk/utils/TableGen: DAGISelEmitter.cpp DAGISelMatcherGen.cpp Message-ID: <201002160615.o1G6F029014392@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 00:15:00 2010 New Revision: 96333 URL: http://llvm.org/viewvc/llvm-project?rev=96333&view=rev Log: remove now dead code and fixme. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96333&r1=96332&r2=96333&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 00:15:00 2010 @@ -561,7 +561,6 @@ unsigned OpNo = 0; bool NodeHasChain = N->NodeHasProperty(SDNPHasChain, CGP); bool HasChain = N->TreeHasProperty(SDNPHasChain, CGP); - bool EmittedUseCheck = false; if (HasChain) { if (NodeHasChain) OpNo = 1; @@ -571,7 +570,6 @@ std::string ParentName(RootName.begin(), RootName.end()-1); emitCheck("IsProfitableToFold(" + getValueName(RootName) + ", " + getNodeName(ParentName) + ", N)"); - EmittedUseCheck = true; if (NodeHasChain) { // If the immediate use can somehow reach this node through another // path, then can't fold it either or it will create a cycle. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96333&r1=96332&r2=96333&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 00:15:00 2010 @@ -243,8 +243,6 @@ } } - // FIXME: Handle EmittedUseCheck & Flags & .hasOneUse() - for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { // Get the code suitable for matching this child. Move to the child, check // it then move back to the parent. From chandlerc at google.com Tue Feb 16 00:24:19 2010 From: chandlerc at google.com (Chandler Carruth) Date: Mon, 15 Feb 2010 22:24:19 -0800 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp In-Reply-To: <4B79E9E0.3040500@mxc.ca> References: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> <4B79E9E0.3040500@mxc.ca> Message-ID: <74c447501002152224h7c83b568j4e1963122cd886ee@mail.gmail.com> On Mon, Feb 15, 2010 at 4:42 PM, Nick Lewycky wrote: > Chris Lattner wrote: >> Isn't a unit test for this completely overkill? > > Testing methodology-type people would tell you that the real problem is > that the rest of the verifier is lacking tests ... > > ... but really, writing this test case is what led to the fixes in > r96272, r96273 and r96275. Even if we didn't test this in particular, we > should probably have a unit test that F->dump() and FPM.run(F) on > functions that have no module owners still work. > > Ultimately I don't really care. FWIW, I like it. The cost is so low that even just verifying that someone hasn't typoed something egregiously seems to justify it. But I'm one of those testing methodology types... ;] > > Nick > >> >> -Chris >> >> On Feb 15, 2010, at 2:09 PM, Nick Lewycky wrote: >> >>> Author: nicholas >>> Date: Mon Feb 15 16:09:09 2010 >>> New Revision: 96282 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=96282&view=rev >>> Log: >>> Teach the verifier to check the condition on a branch and ensure that it has >>> 'i1' type. >>> >>> Added: >>> ? ? llvm/trunk/unittests/VMCore/VerifierTest.cpp >>> Modified: >>> ? ? llvm/trunk/lib/VMCore/Verifier.cpp >>> >>> Modified: llvm/trunk/lib/VMCore/Verifier.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96282&r1=96281&r2=96282&view=diff >>> >>> ============================================================================== >>> --- llvm/trunk/lib/VMCore/Verifier.cpp (original) >>> +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Feb 15 16:09:09 2010 >>> @@ -317,6 +317,7 @@ >>> ? ? ?void visitStoreInst(StoreInst&SI); >>> ? ? ?void visitInstruction(Instruction&I); >>> ? ? ?void visitTerminatorInst(TerminatorInst&I); >>> + ? ?void visitBranchInst(BranchInst&BI); >>> ? ? ?void visitReturnInst(ReturnInst&RI); >>> ? ? ?void visitSwitchInst(SwitchInst&SI); >>> ? ? ?void visitSelectInst(SelectInst&SI); >>> @@ -749,6 +750,14 @@ >>> ? ?visitInstruction(I); >>> } >>> >>> +void Verifier::visitBranchInst(BranchInst&BI) { >>> + ?if (BI.isConditional()) { >>> + ? ?Assert2(BI.getCondition()->getType()->isIntegerTy(1), >>> + ? ? ? ? ? ?"Branch condition is not 'i1' type!",&BI, BI.getCondition()); >>> + ?} >>> + ?visitTerminatorInst(BI); >>> +} >>> + >>> void Verifier::visitReturnInst(ReturnInst&RI) { >>> ? ?Function *F = RI.getParent()->getParent(); >>> ? ?unsigned N = RI.getNumOperands(); >>> >>> Added: llvm/trunk/unittests/VMCore/VerifierTest.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/VerifierTest.cpp?rev=96282&view=auto >>> >>> ============================================================================== >>> --- llvm/trunk/unittests/VMCore/VerifierTest.cpp (added) >>> +++ llvm/trunk/unittests/VMCore/VerifierTest.cpp Mon Feb 15 16:09:09 2010 >>> @@ -0,0 +1,44 @@ >>> +//===- llvm/unittest/VMCore/VerifierTest.cpp - Verifier unit tests --------===// >>> +// >>> +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >>> +// >>> +// This file is distributed under the University of Illinois Open Source >>> +// License. See LICENSE.TXT for details. >>> +// >>> +//===----------------------------------------------------------------------===// >>> + >>> +#include "llvm/Constants.h" >>> +#include "llvm/DerivedTypes.h" >>> +#include "llvm/Function.h" >>> +#include "llvm/Instructions.h" >>> +#include "llvm/LLVMContext.h" >>> +#include "llvm/Analysis/Verifier.h" >>> +#include "gtest/gtest.h" >>> + >>> +namespace llvm { >>> +namespace { >>> + >>> +TEST(VerifierTest, Branch_i1) { >>> + ?LLVMContext&C = getGlobalContext(); >>> + ?FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); >>> + ?Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage); >>> + ?BasicBlock *Entry = BasicBlock::Create(C, "entry", F); >>> + ?BasicBlock *Exit = BasicBlock::Create(C, "exit", F); >>> + ?ReturnInst::Create(C, Exit); >>> + >>> + ?// To avoid triggering an assertion in BranchInst::Create, we first create >>> + ?// a branch with an 'i1' condition ... >>> + >>> + ?Constant *False = ConstantInt::getFalse(C); >>> + ?BranchInst *BI = BranchInst::Create(Exit, Exit, False, Entry); >>> + >>> + ?// ... then use setOperand to redirect it to a value of different type. >>> + >>> + ?Constant *Zero32 = ConstantInt::get(IntegerType::get(C, 32), 0); >>> + ?BI->setOperand(0, Zero32); >>> + >>> + ?EXPECT_TRUE(verifyFunction(*F, ReturnStatusAction)); >>> +} >>> + >>> +} >>> +} >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From clattner at apple.com Tue Feb 16 00:36:23 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Feb 2010 22:36:23 -0800 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp In-Reply-To: <74c447501002152224h7c83b568j4e1963122cd886ee@mail.gmail.com> References: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> <4B79E9E0.3040500@mxc.ca> <74c447501002152224h7c83b568j4e1963122cd886ee@mail.gmail.com> Message-ID: <1B1B8041-800F-4D49-8E98-B529239C1198@apple.com> On Feb 15, 2010, at 10:24 PM, Chandler Carruth wrote: > On Mon, Feb 15, 2010 at 4:42 PM, Nick Lewycky wrote: >> Chris Lattner wrote: >>> Isn't a unit test for this completely overkill? >> >> Testing methodology-type people would tell you that the real problem is >> that the rest of the verifier is lacking tests ... >> >> ... but really, writing this test case is what led to the fixes in >> r96272, r96273 and r96275. Even if we didn't test this in particular, we >> should probably have a unit test that F->dump() and FPM.run(F) on >> functions that have no module owners still work. >> >> Ultimately I don't really care. > > FWIW, I like it. The cost is so low that even just verifying that > someone hasn't typoed something egregiously seems to justify it. But > I'm one of those testing methodology types... ;] I don't like it (if it creeps beyond this) because it adds more uses of the C++ API, meaning that the tests need to be updated when the API changes. Why not use the stable C api for stuff like this? -Chris > >> >> Nick >> >>> >>> -Chris >>> >>> On Feb 15, 2010, at 2:09 PM, Nick Lewycky wrote: >>> >>>> Author: nicholas >>>> Date: Mon Feb 15 16:09:09 2010 >>>> New Revision: 96282 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=96282&view=rev >>>> Log: >>>> Teach the verifier to check the condition on a branch and ensure that it has >>>> 'i1' type. >>>> >>>> Added: >>>> llvm/trunk/unittests/VMCore/VerifierTest.cpp >>>> Modified: >>>> llvm/trunk/lib/VMCore/Verifier.cpp >>>> >>>> Modified: llvm/trunk/lib/VMCore/Verifier.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96282&r1=96281&r2=96282&view=diff >>>> >>>> ============================================================================== >>>> --- llvm/trunk/lib/VMCore/Verifier.cpp (original) >>>> +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Feb 15 16:09:09 2010 >>>> @@ -317,6 +317,7 @@ >>>> void visitStoreInst(StoreInst&SI); >>>> void visitInstruction(Instruction&I); >>>> void visitTerminatorInst(TerminatorInst&I); >>>> + void visitBranchInst(BranchInst&BI); >>>> void visitReturnInst(ReturnInst&RI); >>>> void visitSwitchInst(SwitchInst&SI); >>>> void visitSelectInst(SelectInst&SI); >>>> @@ -749,6 +750,14 @@ >>>> visitInstruction(I); >>>> } >>>> >>>> +void Verifier::visitBranchInst(BranchInst&BI) { >>>> + if (BI.isConditional()) { >>>> + Assert2(BI.getCondition()->getType()->isIntegerTy(1), >>>> + "Branch condition is not 'i1' type!",&BI, BI.getCondition()); >>>> + } >>>> + visitTerminatorInst(BI); >>>> +} >>>> + >>>> void Verifier::visitReturnInst(ReturnInst&RI) { >>>> Function *F = RI.getParent()->getParent(); >>>> unsigned N = RI.getNumOperands(); >>>> >>>> Added: llvm/trunk/unittests/VMCore/VerifierTest.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/VerifierTest.cpp?rev=96282&view=auto >>>> >>>> ============================================================================== >>>> --- llvm/trunk/unittests/VMCore/VerifierTest.cpp (added) >>>> +++ llvm/trunk/unittests/VMCore/VerifierTest.cpp Mon Feb 15 16:09:09 2010 >>>> @@ -0,0 +1,44 @@ >>>> +//===- llvm/unittest/VMCore/VerifierTest.cpp - Verifier unit tests --------===// >>>> +// >>>> +// The LLVM Compiler Infrastructure >>>> +// >>>> +// This file is distributed under the University of Illinois Open Source >>>> +// License. See LICENSE.TXT for details. >>>> +// >>>> +//===----------------------------------------------------------------------===// >>>> + >>>> +#include "llvm/Constants.h" >>>> +#include "llvm/DerivedTypes.h" >>>> +#include "llvm/Function.h" >>>> +#include "llvm/Instructions.h" >>>> +#include "llvm/LLVMContext.h" >>>> +#include "llvm/Analysis/Verifier.h" >>>> +#include "gtest/gtest.h" >>>> + >>>> +namespace llvm { >>>> +namespace { >>>> + >>>> +TEST(VerifierTest, Branch_i1) { >>>> + LLVMContext&C = getGlobalContext(); >>>> + FunctionType *FTy = FunctionType::get(Type::getVoidTy(C), /*isVarArg=*/false); >>>> + Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage); >>>> + BasicBlock *Entry = BasicBlock::Create(C, "entry", F); >>>> + BasicBlock *Exit = BasicBlock::Create(C, "exit", F); >>>> + ReturnInst::Create(C, Exit); >>>> + >>>> + // To avoid triggering an assertion in BranchInst::Create, we first create >>>> + // a branch with an 'i1' condition ... >>>> + >>>> + Constant *False = ConstantInt::getFalse(C); >>>> + BranchInst *BI = BranchInst::Create(Exit, Exit, False, Entry); >>>> + >>>> + // ... then use setOperand to redirect it to a value of different type. >>>> + >>>> + Constant *Zero32 = ConstantInt::get(IntegerType::get(C, 32), 0); >>>> + BI->setOperand(0, Zero32); >>>> + >>>> + EXPECT_TRUE(verifyFunction(*F, ReturnStatusAction)); >>>> +} >>>> + >>>> +} >>>> +} >>>> >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >>> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From sabre at nondot.org Tue Feb 16 00:52:05 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 06:52:05 -0000 Subject: [llvm-commits] [llvm] r96334 - /llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Message-ID: <201002160652.o1G6q80C016034@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 00:52:01 2010 New Revision: 96334 URL: http://llvm.org/viewvc/llvm-project?rev=96334&view=rev Log: refactor some code into a local class. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96334&r1=96333&r2=96334&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Tue Feb 16 00:52:01 2010 @@ -24,10 +24,6 @@ }; } -static unsigned EmitMatcherAndChildren(const MatcherNode *N, - formatted_raw_ostream &FOS, - unsigned Indent); - /// ClassifyInt - Classify an integer by size, return '1','2','4','8' if this /// fits in 1, 2, 4, or 8 sign extended bytes. static char ClassifyInt(int64_t Val) { @@ -67,10 +63,22 @@ return BytesEmitted; } +namespace { +class MatcherTableEmitter { + formatted_raw_ostream &OS; +public: + MatcherTableEmitter(formatted_raw_ostream &os) : OS(os) {} + + unsigned EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent); +private: + unsigned EmitMatcher(const MatcherNode *N, unsigned Indent); +}; +} // end anonymous namespace. + /// EmitMatcherOpcodes - Emit bytes for the specified matcher and return /// the number of bytes emitted. -static unsigned EmitMatcher(const MatcherNode *N, formatted_raw_ostream &OS, - unsigned Indent) { +unsigned MatcherTableEmitter:: +EmitMatcher(const MatcherNode *N, unsigned Indent) { OS.PadToColumn(Indent*2); switch (N->getKind()) { @@ -163,9 +171,8 @@ } /// EmitMatcherAndChildren - Emit the bytes for the specified matcher subtree. -static unsigned EmitMatcherAndChildren(const MatcherNode *N, - formatted_raw_ostream &OS, - unsigned Indent) { +unsigned MatcherTableEmitter:: +EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) { unsigned Size = 0; while (1) { // Push is a special case since it is binary. @@ -179,8 +186,7 @@ raw_svector_ostream OS(TmpBuf); formatted_raw_ostream FOS(OS); ChildSize = - EmitMatcherAndChildren(cast(N)->getChild(), FOS, - Indent+1); + EmitMatcherAndChildren(cast(N)->getChild(),Indent+1); } if (ChildSize > 255) { @@ -199,7 +205,7 @@ continue; } - Size += EmitMatcher(N, OS, Indent); + Size += EmitMatcher(N, Indent); // If there are children of this node, iterate to them, otherwise we're // done. @@ -216,8 +222,10 @@ OS << "// The main instruction selector code.\n"; OS << "SDNode *SelectCode2(SDNode *N) {\n"; + MatcherTableEmitter MatcherEmitter(OS); + OS << " static const unsigned char MatcherTable[] = {\n"; - unsigned TotalSize = EmitMatcherAndChildren(Matcher, OS, 2); + unsigned TotalSize = MatcherEmitter.EmitMatcherAndChildren(Matcher, 2); OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; - OS << " return SelectCodeCommon(N, MatcherTable, sizeof(MatcherTable));\n}\n"; + OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n"; } From sabre at nondot.org Tue Feb 16 01:21:18 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 07:21:18 -0000 Subject: [llvm-commits] [llvm] r96336 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h include/llvm/CodeGen/SelectionDAGISel.h utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp Message-ID: <201002160721.o1G7LOvC017260@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 01:21:10 2010 New Revision: 96336 URL: http://llvm.org/viewvc/llvm-project?rev=96336&view=rev Log: generate code for node and pattern predicates. Note that this won't build if enabled, it will fail with constness issues. I'll resolve these next. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96336&r1=96335&r2=96336&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Tue Feb 16 01:21:10 2010 @@ -164,23 +164,29 @@ return true; } -static int8_t GetInt1(const unsigned char *MatcherTable, unsigned &Idx) { +// These functions are marked always inline so that Idx doesn't get pinned to +// the stack. +ALWAYS_INLINE static int8_t +GetInt1(const unsigned char *MatcherTable, unsigned &Idx) { return MatcherTable[Idx++]; } -static int16_t GetInt2(const unsigned char *MatcherTable, unsigned &Idx) { +ALWAYS_INLINE static int16_t +GetInt2(const unsigned char *MatcherTable, unsigned &Idx) { int16_t Val = GetInt1(MatcherTable, Idx); Val |= int16_t(GetInt1(MatcherTable, Idx)) << 8; return Val; } -static int32_t GetInt4(const unsigned char *MatcherTable, unsigned &Idx) { +ALWAYS_INLINE static int32_t +GetInt4(const unsigned char *MatcherTable, unsigned &Idx) { int32_t Val = GetInt2(MatcherTable, Idx); Val |= int32_t(GetInt2(MatcherTable, Idx)) << 16; return Val; } -static int64_t GetInt8(const unsigned char *MatcherTable, unsigned &Idx) { +ALWAYS_INLINE static int64_t +GetInt8(const unsigned char *MatcherTable, unsigned &Idx) { int64_t Val = GetInt4(MatcherTable, Idx); Val |= int64_t(GetInt4(MatcherTable, Idx)) << 32; return Val; @@ -308,18 +314,12 @@ if (N != RecordedNodes[RecNo]) break; continue; } - case OPC_CheckPatternPredicate: { - unsigned PredNo = MatcherTable[MatcherIndex++]; - (void)PredNo; - // FIXME: CHECK IT. + case OPC_CheckPatternPredicate: + if (!CheckPatternPredicate(MatcherTable[MatcherIndex++])) break; continue; - } - case OPC_CheckPredicate: { - unsigned PredNo = MatcherTable[MatcherIndex++]; - (void)PredNo; - // FIXME: CHECK IT. + case OPC_CheckPredicate: + if (!CheckNodePredicate(N.getNode(), MatcherTable[MatcherIndex++])) break; continue; - } case OPC_CheckComplexPat: { unsigned PatNo = MatcherTable[MatcherIndex++]; (void)PatNo; Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=96336&r1=96335&r2=96336&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Tue Feb 16 01:21:10 2010 @@ -112,6 +112,25 @@ bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS, int64_t DesiredMaskS) const; + + /// CheckPatternPredicate - This function is generated by tblgen in the + /// target. It runs the specified pattern predicate and returns true if it + /// succeeds or false if it fails. The number is a private implementation + /// detail to the code tblgen produces. + virtual bool CheckPatternPredicate(unsigned PredNo) const { + assert(0 && "Tblgen should generate the implementation of this!"); + return 0; + } + + /// CheckNodePredicate - This function is generated by tblgen in the + /// target. It runs node predicate #PredNo and returns true if it succeeds or + /// false if it fails. The number is a private implementation + /// detail to the code tblgen produces. + virtual bool CheckNodePredicate(SDNode *N, unsigned PredNo) const { + assert(0 && "Tblgen should generate the implementation of this!"); + return 0; + } + // Calls to these functions are generated by tblgen. SDNode *Select_INLINEASM(SDNode *N); SDNode *Select_UNDEF(SDNode *N); Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96336&r1=96335&r2=96336&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Tue Feb 16 01:21:10 2010 @@ -10,9 +10,10 @@ #ifndef TBLGEN_DAGISELMATCHER_H #define TBLGEN_DAGISELMATCHER_H +#include "llvm/CodeGen/ValueTypes.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" -#include "llvm/CodeGen/ValueTypes.h" +#include "llvm/Support/Casting.h" namespace llvm { class CodeGenDAGPatterns; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96336&r1=96335&r2=96336&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Tue Feb 16 01:21:10 2010 @@ -14,7 +14,7 @@ #include "DAGISelMatcher.h" #include "CodeGenDAGPatterns.h" #include "llvm/ADT/SmallString.h" -#include "llvm/Support/Casting.h" +#include "llvm/ADT/StringMap.h" #include "llvm/Support/FormattedStream.h" using namespace llvm; @@ -66,12 +66,35 @@ namespace { class MatcherTableEmitter { formatted_raw_ostream &OS; + + StringMap NodePredicateMap, PatternPredicateMap; + std::vector NodePredicates, PatternPredicates; + public: MatcherTableEmitter(formatted_raw_ostream &os) : OS(os) {} unsigned EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent); + + void EmitPredicateFunctions(); private: unsigned EmitMatcher(const MatcherNode *N, unsigned Indent); + + unsigned getNodePredicate(StringRef PredName) { + unsigned &Entry = NodePredicateMap[PredName]; + if (Entry == 0) { + NodePredicates.push_back(PredName.str()); + Entry = NodePredicates.size(); + } + return Entry-1; + } + unsigned getPatternPredicate(StringRef PredName) { + unsigned &Entry = PatternPredicateMap[PredName]; + if (Entry == 0) { + PatternPredicates.push_back(PredName.str()); + Entry = PatternPredicates.size(); + } + return Entry-1; + } }; } // end anonymous namespace. @@ -107,18 +130,19 @@ << cast(N)->getMatchNumber() << ",\n"; return 2; - case MatcherNode::CheckPatternPredicate: - OS << "OPC_CheckPatternPredicate, /*XXX*/0,"; - OS.PadToColumn(CommentIndent) << "// " - << cast(N)->getPredicate() << '\n'; + case MatcherNode::CheckPatternPredicate: { + StringRef Pred = cast(N)->getPredicate(); + OS << "OPC_CheckPatternPredicate, " << getPatternPredicate(Pred) << ','; + OS.PadToColumn(CommentIndent) << "// " << Pred << '\n'; return 2; - - case MatcherNode::CheckPredicate: - OS << "OPC_CheckPredicate, /*XXX*/0,"; - OS.PadToColumn(CommentIndent) << "// " - << cast(N)->getPredicateName() << '\n'; + } + case MatcherNode::CheckPredicate: { + StringRef Pred = cast(N)->getPredicateName(); + OS << "OPC_CheckPredicate, " << getNodePredicate(Pred) << ','; + OS.PadToColumn(CommentIndent) << "// " << Pred << '\n'; return 2; - + } + case MatcherNode::CheckOpcode: OS << "OPC_CheckOpcode, " << cast(N)->getOpcodeName() << ",\n"; @@ -216,6 +240,25 @@ } } +void MatcherTableEmitter::EmitPredicateFunctions() { + OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n"; + OS << " switch (PredNo) {\n"; + OS << " default: assert(0 && \"Invalid predicate in table?\");\n"; + for (unsigned i = 0, e = PatternPredicates.size(); i != e; ++i) + OS << " case " << i << ": return " << PatternPredicates[i] << ";\n"; + OS << " }\n"; + OS << "}\n\n"; + + OS << "bool CheckNodePredicate(SDNode *N, unsigned PredNo) const {\n"; + OS << " switch (PredNo) {\n"; + OS << " default: assert(0 && \"Invalid predicate in table?\");\n"; + for (unsigned i = 0, e = NodePredicates.size(); i != e; ++i) + OS << " case " << i << ": return " << NodePredicates[i] << "(N);\n"; + OS << " }\n"; + OS << "}\n\n"; +} + + void llvm::EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &O) { formatted_raw_ostream OS(O); @@ -228,4 +271,8 @@ unsigned TotalSize = MatcherEmitter.EmitMatcherAndChildren(Matcher, 2); OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n"; + OS << "\n"; + + // Next up, emit the function for node and pattern predicates: + MatcherEmitter.EmitPredicateFunctions(); } From sabre at nondot.org Tue Feb 16 01:26:37 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 07:26:37 -0000 Subject: [llvm-commits] [llvm] r96337 - in /llvm/trunk: lib/Target/Alpha/AlphaISelDAGToDAG.cpp utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002160726.o1G7QcNl017484@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 01:26:36 2010 New Revision: 96337 URL: http://llvm.org/viewvc/llvm-project?rev=96337&view=rev Log: mark all the generated node predicates 'const'. Modified: llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp?rev=96337&r1=96336&r2=96337&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Tue Feb 16 01:26:36 2010 @@ -64,7 +64,7 @@ /// that the bits 1-7 of LHS are already zero. If LHS is non-null, we are /// in checking mode. If LHS is null, we assume that the mask has already /// been validated before. - uint64_t get_zapImm(SDValue LHS, uint64_t Constant) { + uint64_t get_zapImm(SDValue LHS, uint64_t Constant) const { uint64_t BitsToCheck = 0; unsigned Result = 0; for (unsigned i = 0; i != 8; ++i) { Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96337&r1=96336&r2=96337&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 01:26:36 2010 @@ -270,14 +270,14 @@ if (P->getOnlyTree()->isLeaf()) OS << "inline bool Predicate_" << PatFragRecord->getName() - << "(SDNode *N) {\n"; + << "(SDNode *N) const {\n"; else { std::string ClassName = CGP.getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName(); const char *C2 = ClassName == "SDNode" ? "N" : "inN"; OS << "inline bool Predicate_" << PatFragRecord->getName() - << "(SDNode *" << C2 << ") {\n"; + << "(SDNode *" << C2 << ") const {\n"; if (ClassName != "SDNode") OS << " " << ClassName << " *N = cast<" << ClassName << ">(inN);\n"; } From devang.patel at gmail.com Tue Feb 16 01:45:24 2010 From: devang.patel at gmail.com (Devang Patel) Date: Mon, 15 Feb 2010 23:45:24 -0800 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: <6a8523d61002150947gff763eflfe7bdd4069502c9e@mail.gmail.com> References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> <0E341BE8-60FA-47CB-99B7-3F1301AC1ADA@apple.com> <6a8523d61002150933h385d414du39e45901666824c@mail.gmail.com> <201002151138.37172.dag@cray.com> <6a8523d61002150947gff763eflfe7bdd4069502c9e@mail.gmail.com> Message-ID: <352a1fb21002152345x41b182d1tc1696e86f2f3d3fb@mail.gmail.com> >> The verifier has saved me many times. ?I would hate to move this call out of >> LLVM proper. ?We've found many problems with LSR in the past. ?Perhaps Nicolas >> can describe his use-case and we can find a solution that works for everyone. > Note, -verify-each is already available if someone wants to use verifier's help to investigate problem(s). - Devang From devang.patel at gmail.com Tue Feb 16 01:49:42 2010 From: devang.patel at gmail.com (Devang Patel) Date: Mon, 15 Feb 2010 23:49:42 -0800 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> Message-ID: <352a1fb21002152349v3b61242cnbb1a99f97fa018c4@mail.gmail.com> > + ? ? ? ? ?if (SE.isSCEVable(PN->getType()) && > + ? ? ? ? ? ? ?(SE.getEffectiveSCEVType(PN->getType()) == > + ? ? ? ? ? ? ? SE.getEffectiveSCEVType(AR->getType())) && > + ? ? ? ? ? ? ?SE.getSCEV(PN) == AR) > + ? ? ? ? ? ?goto no_cost; > + goto! - Devang From benny.kra at googlemail.com Tue Feb 16 04:25:11 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 16 Feb 2010 10:25:11 -0000 Subject: [llvm-commits] [llvm] r96343 - in /llvm/trunk/lib/Target/X86: X86MCAsmInfo.cpp X86TargetObjectFile.h Message-ID: <201002161025.o1GAPG4R002449@zion.cs.uiuc.edu> Author: d0k Date: Tue Feb 16 04:25:04 2010 New Revision: 96343 URL: http://llvm.org/viewvc/llvm-project?rev=96343&view=rev Log: Minor warning fixes (semicolons, newline at EOF). Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=96343&r1=96342&r2=96343&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Tue Feb 16 04:25:04 2010 @@ -94,4 +94,4 @@ X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) { AsmTransCBE = x86_asm_table; AssemblerDialect = AsmWriterFlavor; -} \ No newline at end of file +} Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=96343&r1=96342&r2=96343&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Tue Feb 16 04:25:04 2010 @@ -49,7 +49,7 @@ const X86TargetMachine &TM; public: X8632_ELFTargetObjectFile(const X86TargetMachine &tm) - :TM(tm) { }; + :TM(tm) { } virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; virtual unsigned getFDEEncoding() const; @@ -60,7 +60,7 @@ const X86TargetMachine &TM; public: X8664_ELFTargetObjectFile(const X86TargetMachine &tm) - :TM(tm) { }; + :TM(tm) { } virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; virtual unsigned getFDEEncoding() const; From baldrick at free.fr Tue Feb 16 05:11:15 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 11:11:15 -0000 Subject: [llvm-commits] [llvm] r96344 - in /llvm/trunk: include/llvm/ lib/Analysis/ lib/Analysis/IPA/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/ lib/ExecutionEngine/Interpreter/ lib/ExecutionEngine/JIT/ lib/Target/ lib/Target/CBackend/ lib/Target/MSIL/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ Message-ID: <201002161111.o1GBBIPo010828@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 05:11:14 2010 New Revision: 96344 URL: http://llvm.org/viewvc/llvm-project?rev=96344&view=rev Log: There are two ways of checking for a given type, for example isa(T) and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. Modified: llvm/trunk/include/llvm/Instructions.h llvm/trunk/include/llvm/Type.h llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp llvm/trunk/lib/Analysis/CaptureTracking.cpp llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/IPA/Andersens.cpp llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp llvm/trunk/lib/Analysis/InlineCost.cpp llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp llvm/trunk/lib/Analysis/PointerTracking.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/MSIL/MSILWriter.cpp llvm/trunk/lib/Target/TargetData.cpp llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/ABCD.cpp llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/lib/Transforms/Scalar/LICM.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp llvm/trunk/lib/Transforms/Utils/Local.cpp llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp llvm/trunk/lib/VMCore/Attributes.cpp llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/InlineAsm.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/lib/VMCore/Value.cpp llvm/trunk/lib/VMCore/ValueTypes.cpp llvm/trunk/lib/VMCore/Verifier.cpp llvm/trunk/tools/bugpoint/CrashDebugger.cpp llvm/trunk/tools/bugpoint/ExtractFunction.cpp Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Tue Feb 16 05:11:14 2010 @@ -591,7 +591,7 @@ "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } @@ -612,7 +612,7 @@ "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } @@ -631,7 +631,7 @@ "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - isa(getOperand(0)->getType())) && + getOperand(0)->getType()->isPointerTy()) && "Invalid operand types for ICmp instruction"); } Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Tue Feb 16 05:11:14 2010 @@ -243,6 +243,10 @@ /// bool isStructTy() const { return ID == StructTyID; } + /// isUnionTy - True if this is an instance of UnionType. + /// + bool isUnionTy() const { return ID == UnionTyID; } + /// isArrayTy - True if this is an instance of ArrayType. /// bool isArrayTy() const { return ID == ArrayTyID; } Modified: llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp (original) +++ llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp Tue Feb 16 05:11:14 2010 @@ -115,11 +115,11 @@ SetVector CallSites; for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) - if (isa(I->getType())) // Add all pointer arguments + if (I->getType()->isPointerTy()) // Add all pointer arguments Pointers.insert(I); for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { - if (isa(I->getType())) // Add all pointer instructions + if (I->getType()->isPointerTy()) // Add all pointer instructions Pointers.insert(&*I); Instruction &Inst = *I; User::op_iterator OI = Inst.op_begin(); @@ -128,7 +128,7 @@ isa(CS.getCalledValue())) ++OI; // Skip actual functions for direct function calls. for (; OI != Inst.op_end(); ++OI) - if (isa((*OI)->getType()) && !isa(*OI)) + if ((*OI)->getType()->isPointerTy() && !isa(*OI)) Pointers.insert(*OI); if (CS.getInstruction()) CallSites.insert(CS); Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Feb 16 05:11:14 2010 @@ -290,7 +290,7 @@ for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); CI != CE; ++CI, ++ArgNo) { // Only look at the no-capture pointer arguments. - if (!isa((*CI)->getType()) || + if (!(*CI)->getType()->isPointerTy() || !CS.paramHasAttr(ArgNo+1, Attribute::NoCapture)) continue; @@ -662,7 +662,7 @@ // Are we checking for alias of the same value? if (V1 == V2) return MustAlias; - if (!isa(V1->getType()) || !isa(V2->getType())) + if (!V1->getType()->isPointerTy() || !V2->getType()->isPointerTy()) return NoAlias; // Scalars cannot alias each other // Figure out what objects these things are pointing to if we can. Modified: llvm/trunk/lib/Analysis/CaptureTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CaptureTracking.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CaptureTracking.cpp (original) +++ llvm/trunk/lib/Analysis/CaptureTracking.cpp Tue Feb 16 05:11:14 2010 @@ -44,7 +44,7 @@ /// counts as capturing it or not. bool llvm::PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures) { - assert(isa(V->getType()) && "Capture is for pointers only!"); + assert(V->getType()->isPointerTy() && "Capture is for pointers only!"); SmallVector Worklist; SmallSet Visited; int Count = 0; Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Feb 16 05:11:14 2010 @@ -359,7 +359,7 @@ MapTy = Type::getInt32PtrTy(C->getContext()); else if (LoadTy->isDoubleTy()) MapTy = Type::getInt64PtrTy(C->getContext()); - else if (isa(LoadTy)) { + else if (LoadTy->isVectorTy()) { MapTy = IntegerType::get(C->getContext(), TD.getTypeAllocSizeInBits(LoadTy)); MapTy = PointerType::getUnqual(MapTy); @@ -605,7 +605,7 @@ SmallVector NewIdxs; do { if (const SequentialType *ATy = dyn_cast(Ty)) { - if (isa(ATy)) { + if (ATy->isPointerTy()) { // The only pointer indexing we'll do is on the first index of the GEP. if (!NewIdxs.empty()) break; Modified: llvm/trunk/lib/Analysis/IPA/Andersens.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/Andersens.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/Andersens.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/Andersens.cpp Tue Feb 16 05:11:14 2010 @@ -750,7 +750,7 @@ // The function itself is a memory object. unsigned First = NumObjects; ValueNodes[F] = NumObjects++; - if (isa(F->getFunctionType()->getReturnType())) + if (F->getFunctionType()->getReturnType()->isPointerTy()) ReturnNodes[F] = NumObjects++; if (F->getFunctionType()->isVarArg()) VarargNodes[F] = NumObjects++; @@ -760,7 +760,7 @@ for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) { - if (isa(I->getType())) + if (I->getType()->isPointerTy()) ValueNodes[I] = NumObjects++; } MaxK[First] = NumObjects - First; @@ -771,7 +771,7 @@ for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) { // If this is an heap or stack allocation, create a node for the memory // object. - if (isa(II->getType())) { + if (II->getType()->isPointerTy()) { ValueNodes[&*II] = NumObjects++; if (AllocaInst *AI = dyn_cast(&*II)) ObjectNodes[AI] = NumObjects++; @@ -801,7 +801,7 @@ /// getNodeForConstantPointer - Return the node corresponding to the constant /// pointer itself. unsigned Andersens::getNodeForConstantPointer(Constant *C) { - assert(isa(C->getType()) && "Not a constant pointer!"); + assert(C->getType()->isPointerTy() && "Not a constant pointer!"); if (isa(C) || isa(C)) return NullPtr; @@ -828,7 +828,7 @@ /// getNodeForConstantPointerTarget - Return the node POINTED TO by the /// specified constant pointer. unsigned Andersens::getNodeForConstantPointerTarget(Constant *C) { - assert(isa(C->getType()) && "Not a constant pointer!"); + assert(C->getType()->isPointerTy() && "Not a constant pointer!"); if (isa(C)) return NullObject; @@ -857,7 +857,7 @@ void Andersens::AddGlobalInitializerConstraints(unsigned NodeIndex, Constant *C) { if (C->getType()->isSingleValueType()) { - if (isa(C->getType())) + if (C->getType()->isPointerTy()) Constraints.push_back(Constraint(Constraint::Copy, NodeIndex, getNodeForConstantPointer(C))); } else if (C->isNullValue()) { @@ -878,7 +878,7 @@ /// returned by this function. void Andersens::AddConstraintsForNonInternalLinkage(Function *F) { for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) - if (isa(I->getType())) + if (I->getType()->isPointerTy()) // If this is an argument of an externally accessible function, the // incoming pointer might point to anything. Constraints.push_back(Constraint(Constraint::Copy, getNode(I), @@ -940,8 +940,8 @@ const FunctionType *FTy = F->getFunctionType(); if (FTy->getNumParams() > 1 && - isa(FTy->getParamType(0)) && - isa(FTy->getParamType(1))) { + FTy->getParamType(0)->isPointerTy() && + FTy->getParamType(1)->isPointerTy()) { // *Dest = *Src, which requires an artificial graph node to represent the // constraint. It is broken up into *Dest = temp, temp = *Src @@ -966,7 +966,7 @@ F->getName() == "strtok") { const FunctionType *FTy = F->getFunctionType(); if (FTy->getNumParams() > 0 && - isa(FTy->getParamType(0))) { + FTy->getParamType(0)->isPointerTy()) { Constraints.push_back(Constraint(Constraint::Copy, getNode(CS.getInstruction()), getNode(CS.getArgument(0)))); @@ -984,7 +984,7 @@ /// true. bool Andersens::AnalyzeUsesOfFunction(Value *V) { - if (!isa(V->getType())) return true; + if (!V->getType()->isPointerTy()) return true; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) if (isa(*UI)) { @@ -1063,7 +1063,7 @@ for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) { // Set up the return value node. - if (isa(F->getFunctionType()->getReturnType())) + if (F->getFunctionType()->getReturnType()->isPointerTy()) GraphNodes[getReturnNode(F)].setValue(F); if (F->getFunctionType()->isVarArg()) GraphNodes[getVarargNode(F)].setValue(F); @@ -1071,7 +1071,7 @@ // Set up incoming argument nodes. for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) - if (isa(I->getType())) + if (I->getType()->isPointerTy()) getNodeValue(*I); // At some point we should just add constraints for the escaping functions @@ -1087,7 +1087,7 @@ visit(F); } else { // External functions that return pointers return the universal set. - if (isa(F->getFunctionType()->getReturnType())) + if (F->getFunctionType()->getReturnType()->isPointerTy()) Constraints.push_back(Constraint(Constraint::Copy, getReturnNode(F), UniversalSet)); @@ -1096,7 +1096,7 @@ // stored into them. for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) - if (isa(I->getType())) { + if (I->getType()->isPointerTy()) { // Pointers passed into external functions could have anything stored // through them. Constraints.push_back(Constraint(Constraint::Store, getNode(I), @@ -1159,7 +1159,7 @@ } void Andersens::visitReturnInst(ReturnInst &RI) { - if (RI.getNumOperands() && isa(RI.getOperand(0)->getType())) + if (RI.getNumOperands() && RI.getOperand(0)->getType()->isPointerTy()) // return V --> Constraints.push_back(Constraint(Constraint::Copy, getReturnNode(RI.getParent()->getParent()), @@ -1167,14 +1167,14 @@ } void Andersens::visitLoadInst(LoadInst &LI) { - if (isa(LI.getType())) + if (LI.getType()->isPointerTy()) // P1 = load P2 --> Constraints.push_back(Constraint(Constraint::Load, getNodeValue(LI), getNode(LI.getOperand(0)))); } void Andersens::visitStoreInst(StoreInst &SI) { - if (isa(SI.getOperand(0)->getType())) + if (SI.getOperand(0)->getType()->isPointerTy()) // store P1, P2 --> Constraints.push_back(Constraint(Constraint::Store, getNode(SI.getOperand(1)), @@ -1188,7 +1188,7 @@ } void Andersens::visitPHINode(PHINode &PN) { - if (isa(PN.getType())) { + if (PN.getType()->isPointerTy()) { unsigned PNN = getNodeValue(PN); for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) // P1 = phi P2, P3 --> , , ... @@ -1199,8 +1199,8 @@ void Andersens::visitCastInst(CastInst &CI) { Value *Op = CI.getOperand(0); - if (isa(CI.getType())) { - if (isa(Op->getType())) { + if (CI.getType()->isPointerTy()) { + if (Op->getType()->isPointerTy()) { // P1 = cast P2 --> Constraints.push_back(Constraint(Constraint::Copy, getNodeValue(CI), getNode(CI.getOperand(0)))); @@ -1213,7 +1213,7 @@ getNodeValue(CI); #endif } - } else if (isa(Op->getType())) { + } else if (Op->getType()->isPointerTy()) { // int = cast P1 --> #if 0 Constraints.push_back(Constraint(Constraint::Copy, @@ -1226,7 +1226,7 @@ } void Andersens::visitSelectInst(SelectInst &SI) { - if (isa(SI.getType())) { + if (SI.getType()->isPointerTy()) { unsigned SIN = getNodeValue(SI); // P1 = select C, P2, P3 ---> , Constraints.push_back(Constraint(Constraint::Copy, SIN, @@ -1254,9 +1254,9 @@ if (F && F->isDeclaration() && AddConstraintsForExternalCall(CS, F)) return; - if (isa(CS.getType())) { + if (CS.getType()->isPointerTy()) { unsigned CSN = getNode(CS.getInstruction()); - if (!F || isa(F->getFunctionType()->getReturnType())) { + if (!F || F->getFunctionType()->getReturnType()->isPointerTy()) { if (IsDeref) Constraints.push_back(Constraint(Constraint::Load, CSN, getNode(CallValue), CallReturnPos)); @@ -1269,7 +1269,7 @@ Constraints.push_back(Constraint(Constraint::Copy, CSN, UniversalSet)); } - } else if (F && isa(F->getFunctionType()->getReturnType())) { + } else if (F && F->getFunctionType()->getReturnType()->isPointerTy()) { #if FULL_UNIVERSAL Constraints.push_back(Constraint(Constraint::Copy, UniversalSet, @@ -1291,7 +1291,7 @@ for (; AI != AE && ArgI != ArgE; ++AI, ++ArgI) { #if !FULL_UNIVERSAL - if (external && isa((*ArgI)->getType())) + if (external && (*ArgI)->getType()->isPointerTy()) { // Add constraint that ArgI can now point to anything due to // escaping, as can everything it points to. The second portion of @@ -1301,8 +1301,8 @@ UniversalSet)); } #endif - if (isa(AI->getType())) { - if (isa((*ArgI)->getType())) { + if (AI->getType()->isPointerTy()) { + if ((*ArgI)->getType()->isPointerTy()) { // Copy the actual argument into the formal argument. Constraints.push_back(Constraint(Constraint::Copy, getNode(AI), getNode(*ArgI))); @@ -1310,7 +1310,7 @@ Constraints.push_back(Constraint(Constraint::Copy, getNode(AI), UniversalSet)); } - } else if (isa((*ArgI)->getType())) { + } else if ((*ArgI)->getType()->isPointerTy()) { #if FULL_UNIVERSAL Constraints.push_back(Constraint(Constraint::Copy, UniversalSet, @@ -1326,7 +1326,7 @@ //Indirect Call unsigned ArgPos = CallFirstArgPos; for (; ArgI != ArgE; ++ArgI) { - if (isa((*ArgI)->getType())) { + if ((*ArgI)->getType()->isPointerTy()) { // Copy the actual argument into the formal argument. Constraints.push_back(Constraint(Constraint::Store, getNode(CallValue), @@ -1341,14 +1341,14 @@ // Copy all pointers passed through the varargs section to the varargs node. if (F && F->getFunctionType()->isVarArg()) for (; ArgI != ArgE; ++ArgI) - if (isa((*ArgI)->getType())) + if ((*ArgI)->getType()->isPointerTy()) Constraints.push_back(Constraint(Constraint::Copy, getVarargNode(F), getNode(*ArgI))); // If more arguments are passed in than we track, just drop them on the floor. } void Andersens::visitCallSite(CallSite CS) { - if (isa(CS.getType())) + if (CS.getType()->isPointerTy()) getNodeValue(*CS.getInstruction()); if (Function *F = CS.getCalledFunction()) { @@ -2782,7 +2782,7 @@ assert(N->getValue() != 0 && "Never set node label!"); Value *V = N->getValue(); if (Function *F = dyn_cast(V)) { - if (isa(F->getFunctionType()->getReturnType()) && + if (F->getFunctionType()->getReturnType()->isPointerTy() && N == &GraphNodes[getReturnNode(F)]) { dbgs() << F->getName() << ":retval"; return; Modified: llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/GlobalsModRef.cpp Tue Feb 16 05:11:14 2010 @@ -213,7 +213,7 @@ ++NumNonAddrTakenGlobalVars; // If this global holds a pointer type, see if it is an indirect global. - if (isa(I->getType()->getElementType()) && + if (I->getType()->getElementType()->isPointerTy() && AnalyzeIndirectGlobalMemory(I)) ++NumIndirectGlobalVars; } @@ -231,7 +231,7 @@ std::vector &Readers, std::vector &Writers, GlobalValue *OkayStoreDest) { - if (!isa(V->getType())) return true; + if (!V->getType()->isPointerTy()) return true; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) if (LoadInst *LI = dyn_cast(*UI)) { Modified: llvm/trunk/lib/Analysis/InlineCost.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InlineCost.cpp (original) +++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Feb 16 05:11:14 2010 @@ -84,7 +84,7 @@ // unsigned InlineCostAnalyzer::FunctionInfo:: CountCodeReductionForAlloca(Value *V) { - if (!isa(V->getType())) return 0; // Not a pointer + if (!V->getType()->isPointerTy()) return 0; // Not a pointer unsigned Reduction = 0; for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){ Instruction *I = cast(*UI); @@ -175,7 +175,7 @@ this->usesDynamicAlloca = true; } - if (isa(II) || isa(II->getType())) + if (isa(II) || II->getType()->isVectorTy()) ++NumVectorInsts; if (const CastInst *CI = dyn_cast(II)) { Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Feb 16 05:11:14 2010 @@ -580,7 +580,7 @@ void MemoryDependenceAnalysis:: getNonLocalPointerDependency(Value *Pointer, bool isLoad, BasicBlock *FromBB, SmallVectorImpl &Result) { - assert(isa(Pointer->getType()) && + assert(Pointer->getType()->isPointerTy() && "Can't get pointer deps of a non-pointer!"); Result.clear(); @@ -1009,7 +1009,7 @@ /// in more places that cached info does not necessarily keep. void MemoryDependenceAnalysis::invalidateCachedPointerInfo(Value *Ptr) { // If Ptr isn't really a pointer, just ignore it. - if (!isa(Ptr->getType())) return; + if (!Ptr->getType()->isPointerTy()) return; // Flush store info for the pointer. RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, false)); // Flush load info for the pointer. @@ -1050,7 +1050,7 @@ // Remove it from both the load info and the store info. The instruction // can't be in either of these maps if it is non-pointer. - if (isa(RemInst->getType())) { + if (RemInst->getType()->isPointerTy()) { RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, false)); RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, true)); } Modified: llvm/trunk/lib/Analysis/PointerTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PointerTracking.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/PointerTracking.cpp (original) +++ llvm/trunk/lib/Analysis/PointerTracking.cpp Tue Feb 16 05:11:14 2010 @@ -231,7 +231,7 @@ // this should be safe for the same reason its safe for SCEV. PointerTracking &PT = *const_cast(this); for (inst_iterator I=inst_begin(*FF), E=inst_end(*FF); I != E; ++I) { - if (!isa(I->getType())) + if (!I->getType()->isPointerTy()) continue; Value *Base; const SCEV *Limit, *Offset; Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Feb 16 05:11:14 2010 @@ -214,8 +214,8 @@ SCEVTruncateExpr::SCEVTruncateExpr(const FoldingSetNodeID &ID, const SCEV *op, const Type *ty) : SCEVCastExpr(ID, scTruncate, op, ty) { - assert((Op->getType()->isIntegerTy() || isa(Op->getType())) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((Op->getType()->isIntegerTy() || Op->getType()->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot truncate non-integer value!"); } @@ -226,8 +226,8 @@ SCEVZeroExtendExpr::SCEVZeroExtendExpr(const FoldingSetNodeID &ID, const SCEV *op, const Type *ty) : SCEVCastExpr(ID, scZeroExtend, op, ty) { - assert((Op->getType()->isIntegerTy() || isa(Op->getType())) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((Op->getType()->isIntegerTy() || Op->getType()->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot zero extend non-integer value!"); } @@ -238,8 +238,8 @@ SCEVSignExtendExpr::SCEVSignExtendExpr(const FoldingSetNodeID &ID, const SCEV *op, const Type *ty) : SCEVCastExpr(ID, scSignExtend, op, ty) { - assert((Op->getType()->isIntegerTy() || isa(Op->getType())) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((Op->getType()->isIntegerTy() || Op->getType()->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot sign extend non-integer value!"); } @@ -416,7 +416,7 @@ cast(CE->getOperand(0)->getType())->getElementType(); // Ignore vector types here so that ScalarEvolutionExpander doesn't // emit getelementptrs that index into vectors. - if (isa(Ty) || isa(Ty)) { + if (Ty->isStructTy() || Ty->isArrayTy()) { CTy = Ty; FieldNo = CE->getOperand(2); return true; @@ -518,9 +518,9 @@ // Order pointer values after integer values. This helps SCEVExpander // form GEPs. - if (isa(LU->getType()) && !isa(RU->getType())) + if (LU->getType()->isPointerTy() && !RU->getType()->isPointerTy()) return false; - if (isa(RU->getType()) && !isa(LU->getType())) + if (RU->getType()->isPointerTy() && !LU->getType()->isPointerTy()) return true; // Compare getValueID values. @@ -2308,7 +2308,7 @@ /// has access to target-specific information. bool ScalarEvolution::isSCEVable(const Type *Ty) const { // Integers and pointers are always SCEVable. - return Ty->isIntegerTy() || isa(Ty); + return Ty->isIntegerTy() || Ty->isPointerTy(); } /// getTypeSizeInBits - Return the size in bits of the specified type, @@ -2326,7 +2326,7 @@ // The only other support type is pointer. Without TargetData, conservatively // assume pointers are 64-bit. - assert(isa(Ty) && "isSCEVable permitted a non-SCEVable type!"); + assert(Ty->isPointerTy() && "isSCEVable permitted a non-SCEVable type!"); return 64; } @@ -2341,7 +2341,7 @@ return Ty; // The only other support type is pointer. - assert(isa(Ty) && "Unexpected non-pointer non-integer type!"); + assert(Ty->isPointerTy() && "Unexpected non-pointer non-integer type!"); if (TD) return TD->getIntPtrType(getContext()); // Without TargetData, conservatively assume pointers are 64-bit. @@ -2412,8 +2412,8 @@ ScalarEvolution::getTruncateOrZeroExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isIntegerTy() || isa(SrcTy)) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || SrcTy->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot truncate or zero extend with non-integer arguments!"); if (getTypeSizeInBits(SrcTy) == getTypeSizeInBits(Ty)) return V; // No conversion @@ -2429,8 +2429,8 @@ ScalarEvolution::getTruncateOrSignExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isIntegerTy() || isa(SrcTy)) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || SrcTy->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot truncate or zero extend with non-integer arguments!"); if (getTypeSizeInBits(SrcTy) == getTypeSizeInBits(Ty)) return V; // No conversion @@ -2445,8 +2445,8 @@ const SCEV * ScalarEvolution::getNoopOrZeroExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isIntegerTy() || isa(SrcTy)) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || SrcTy->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot noop or zero extend with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) && "getNoopOrZeroExtend cannot truncate!"); @@ -2461,8 +2461,8 @@ const SCEV * ScalarEvolution::getNoopOrSignExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isIntegerTy() || isa(SrcTy)) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || SrcTy->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot noop or sign extend with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) && "getNoopOrSignExtend cannot truncate!"); @@ -2478,8 +2478,8 @@ const SCEV * ScalarEvolution::getNoopOrAnyExtend(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isIntegerTy() || isa(SrcTy)) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || SrcTy->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot noop or any extend with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty) && "getNoopOrAnyExtend cannot truncate!"); @@ -2493,8 +2493,8 @@ const SCEV * ScalarEvolution::getTruncateOrNoop(const SCEV *V, const Type *Ty) { const Type *SrcTy = V->getType(); - assert((SrcTy->isIntegerTy() || isa(SrcTy)) && - (Ty->isIntegerTy() || isa(Ty)) && + assert((SrcTy->isIntegerTy() || SrcTy->isPointerTy()) && + (Ty->isIntegerTy() || Ty->isPointerTy()) && "Cannot truncate or noop with non-integer arguments!"); assert(getTypeSizeInBits(SrcTy) >= getTypeSizeInBits(Ty) && "getTruncateOrNoop cannot extend!"); Modified: llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp Tue Feb 16 05:11:14 2010 @@ -89,7 +89,7 @@ } else if (const SCEVAddExpr *A = dyn_cast(S)) { // If there's a pointer operand, it'll be sorted at the end of the list. const SCEV *Last = A->getOperand(A->getNumOperands()-1); - if (isa(Last->getType())) + if (Last->getType()->isPointerTy()) return GetBaseValue(Last); } else if (const SCEVUnknown *U = dyn_cast(S)) { // This is a leaf node. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Feb 16 05:11:14 2010 @@ -536,7 +536,7 @@ // pointer type, if there is one, or the last operand otherwise. int PIdx = 0; for (; PIdx != NumOperands - 1; ++PIdx) - if (isa(S->getOperand(PIdx)->getType())) break; + if (S->getOperand(PIdx)->getType()->isPointerTy()) break; // Expand code for the operand that we chose. Value *V = expand(S->getOperand(PIdx)); @@ -702,7 +702,7 @@ // negative, insert a sub instead of an add for the increment (unless it's a // constant, because subtracts of constants are canonicalized to adds). const SCEV *Step = Normalized->getStepRecurrence(SE); - bool isPointer = isa(ExpandTy); + bool isPointer = ExpandTy->isPointerTy(); bool isNegative = !isPointer && isNonConstantNegative(Step); if (isNegative) Step = SE.getNegativeSCEV(Step); @@ -852,7 +852,7 @@ PHINode *CanonicalIV = 0; if (PHINode *PN = L->getCanonicalInductionVariable()) if (SE.isSCEVable(PN->getType()) && - isa(SE.getEffectiveSCEVType(PN->getType())) && + SE.getEffectiveSCEVType(PN->getType())->isIntegerTy() && SE.getTypeSizeInBits(PN->getType()) >= SE.getTypeSizeInBits(Ty)) CanonicalIV = PN; Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue Feb 16 05:11:14 2010 @@ -49,7 +49,7 @@ assert(V && "No Value?"); assert(Depth <= MaxDepth && "Limit Search Depth"); unsigned BitWidth = Mask.getBitWidth(); - assert((V->getType()->isIntOrIntVectorTy() || isa(V->getType())) + assert((V->getType()->isIntOrIntVectorTy() || V->getType()->isPointerTy()) && "Not integer or pointer type!"); assert((!TD || TD->getTypeSizeInBits(V->getType()->getScalarType()) == BitWidth) && @@ -249,7 +249,7 @@ unsigned SrcBitWidth; // Note that we handle pointer operands here because of inttoptr/ptrtoint // which fall through here. - if (isa(SrcTy)) + if (SrcTy->isPointerTy()) SrcBitWidth = TD->getTypeSizeInBits(SrcTy); else SrcBitWidth = SrcTy->getScalarSizeInBits(); @@ -269,10 +269,10 @@ } case Instruction::BitCast: { const Type *SrcTy = I->getOperand(0)->getType(); - if ((SrcTy->isIntegerTy() || isa(SrcTy)) && + if ((SrcTy->isIntegerTy() || SrcTy->isPointerTy()) && // TODO: For now, not handling conversions like: // (bitcast i64 %x to <2 x i32>) - !isa(I->getType())) { + !I->getType()->isVectorTy()) { ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, TD, Depth+1); return; @@ -980,7 +980,7 @@ /// may not be represented in the result. static Value *GetLinearExpression(Value *V, APInt &Scale, APInt &Offset, const TargetData *TD, unsigned Depth) { - assert(isa(V->getType()) && "Not an integer value"); + assert(V->getType()->isIntegerTy() && "Not an integer value"); // Limit our recursion depth. if (Depth == 6) { @@ -1253,7 +1253,7 @@ if (idx_begin == idx_end) return V; // We have indices, so V should have an indexable type - assert((isa(V->getType()) || isa(V->getType())) + assert((V->getType()->isStructTy() || V->getType()->isArrayTy()) && "Not looking at a struct or array?"); assert(ExtractValueInst::getIndexedType(V->getType(), idx_begin, idx_end) && "Invalid indices for type?"); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Feb 16 05:11:14 2010 @@ -614,7 +614,7 @@ Aliasee = ID.ConstantVal; } - if (!isa(Aliasee->getType())) + if (!Aliasee->getType()->isPointerTy()) return Error(AliaseeLoc, "alias must have pointer type"); // Okay, create the alias but do not insert it into the module yet. @@ -685,7 +685,7 @@ return true; } - if (isa(Ty) || Ty->isLabelTy()) + if (Ty->isFunctionTy() || Ty->isLabelTy()) return Error(TyLoc, "invalid type for global variable"); GlobalVariable *GV = 0; @@ -2256,7 +2256,7 @@ } else { assert(Opc == Instruction::ICmp && "Unexpected opcode for CmpInst!"); if (!Val0->getType()->isIntOrIntVectorTy() && - !isa(Val0->getType())) + !Val0->getType()->isPointerTy()) return Error(ID.Loc, "icmp requires pointer or integer operands"); ID.ConstantVal = ConstantExpr::getICmp(Pred, Val0, Val1); } @@ -2370,7 +2370,7 @@ return true; if (Opc == Instruction::GetElementPtr) { - if (Elts.size() == 0 || !isa(Elts[0]->getType())) + if (Elts.size() == 0 || !Elts[0]->getType()->isPointerTy()) return Error(ID.Loc, "getelementptr requires pointer operand"); if (!GetElementPtrInst::getIndexedType(Elts[0]->getType(), @@ -2470,7 +2470,7 @@ bool LLParser::ConvertValIDToValue(const Type *Ty, ValID &ID, Value *&V, PerFunctionState *PFS) { - if (isa(Ty)) + if (Ty->isFunctionTy()) return Error(ID.Loc, "functions are not values, refer to them as pointers"); switch (ID.Kind) { @@ -2509,7 +2509,7 @@ V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc); return V == 0; case ValID::t_APSInt: - if (!isa(Ty)) + if (!Ty->isIntegerTy()) return Error(ID.Loc, "integer constant must have integer type"); ID.APSIntVal.extOrTrunc(Ty->getPrimitiveSizeInBits()); V = ConstantInt::get(Context, ID.APSIntVal); @@ -2535,7 +2535,7 @@ return false; case ValID::t_Null: - if (!isa(Ty)) + if (!Ty->isPointerTy()) return Error(ID.Loc, "null must be a pointer type"); V = ConstantPointerNull::get(cast(Ty)); return false; @@ -2547,7 +2547,7 @@ V = UndefValue::get(Ty); return false; case ValID::t_EmptyArray: - if (!isa(Ty) || cast(Ty)->getNumElements() != 0) + if (!Ty->isArrayTy() || cast(Ty)->getNumElements() != 0) return Error(ID.Loc, "invalid empty array initializer"); V = UndefValue::get(Ty); return false; @@ -3186,7 +3186,7 @@ ParseToken(lltok::lsquare, "expected '[' with switch table")) return true; - if (!isa(Cond->getType())) + if (!Cond->getType()->isIntegerTy()) return Error(CondLoc, "switch condition must have integer type"); // Parse the jump table pairs. @@ -3229,7 +3229,7 @@ ParseToken(lltok::lsquare, "expected '[' with indirectbr")) return true; - if (!isa(Address->getType())) + if (!Address->getType()->isPointerTy()) return Error(AddrLoc, "indirectbr address must have pointer type"); // Parse the destination list. @@ -3436,7 +3436,7 @@ } else { assert(Opc == Instruction::ICmp && "Unknown opcode for CmpInst!"); if (!LHS->getType()->isIntOrIntVectorTy() && - !isa(LHS->getType())) + !LHS->getType()->isPointerTy()) return Error(Loc, "icmp requires integer operands"); Inst = new ICmpInst(CmpInst::Predicate(Pred), LHS, RHS); } @@ -3761,7 +3761,7 @@ BasicBlock* BB) { Value *Val; LocTy Loc; if (ParseTypeAndValue(Val, Loc, PFS)) return true; - if (!isa(Val->getType())) + if (!Val->getType()->isPointerTy()) return Error(Loc, "operand to free must be a pointer"); Inst = CallInst::CreateFree(Val, BB); return false; @@ -3778,7 +3778,7 @@ ParseOptionalCommaAlign(Alignment, AteExtraComma)) return true; - if (!isa(Val->getType()) || + if (!Val->getType()->isPointerTy() || !cast(Val->getType())->getElementType()->isFirstClassType()) return Error(Loc, "load operand must be a pointer to a first class type"); @@ -3799,7 +3799,7 @@ ParseOptionalCommaAlign(Alignment, AteExtraComma)) return true; - if (!isa(Ptr->getType())) + if (!Ptr->getType()->isPointerTy()) return Error(PtrLoc, "store operand must be a pointer"); if (!Val->getType()->isFirstClassType()) return Error(Loc, "store operand must be a first class value"); @@ -3821,7 +3821,7 @@ ParseUInt32(Element, EltLoc)) return true; - if (!isa(Val->getType()) && !isa(Val->getType())) + if (!Val->getType()->isStructTy() && !Val->getType()->isArrayTy()) return Error(ValLoc, "getresult inst requires an aggregate operand"); if (!ExtractValueInst::getIndexedType(Val->getType(), Element)) return Error(EltLoc, "invalid getresult index for value"); @@ -3838,7 +3838,7 @@ if (ParseTypeAndValue(Ptr, Loc, PFS)) return true; - if (!isa(Ptr->getType())) + if (!Ptr->getType()->isPointerTy()) return Error(Loc, "base of getelementptr must be a pointer"); SmallVector Indices; @@ -3849,7 +3849,7 @@ break; } if (ParseTypeAndValue(Val, EltLoc, PFS)) return true; - if (!isa(Val->getType())) + if (!Val->getType()->isIntegerTy()) return Error(EltLoc, "getelementptr index must be an integer"); Indices.push_back(Val); } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Feb 16 05:11:14 2010 @@ -963,12 +963,12 @@ V = Constant::getNullValue(CurTy); break; case bitc::CST_CODE_INTEGER: // INTEGER: [intval] - if (!isa(CurTy) || Record.empty()) + if (!CurTy->isIntegerTy() || Record.empty()) return Error("Invalid CST_INTEGER record"); V = ConstantInt::get(CurTy, DecodeSignRotatedValue(Record[0])); break; case bitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval] - if (!isa(CurTy) || Record.empty()) + if (!CurTy->isIntegerTy() || Record.empty()) return Error("Invalid WIDE_INTEGER record"); unsigned NumWords = Record.size(); @@ -1407,7 +1407,7 @@ if (Record.size() < 6) return Error("Invalid MODULE_CODE_GLOBALVAR record"); const Type *Ty = getTypeByID(Record[0]); - if (!isa(Ty)) + if (!Ty->isPointerTy()) return Error("Global not a pointer type!"); unsigned AddressSpace = cast(Ty)->getAddressSpace(); Ty = cast(Ty)->getElementType(); @@ -1450,7 +1450,7 @@ if (Record.size() < 8) return Error("Invalid MODULE_CODE_FUNCTION record"); const Type *Ty = getTypeByID(Record[0]); - if (!isa(Ty)) + if (!Ty->isPointerTy()) return Error("Function not a pointer type!"); const FunctionType *FTy = dyn_cast(cast(Ty)->getElementType()); @@ -1491,7 +1491,7 @@ if (Record.size() < 3) return Error("Invalid MODULE_ALIAS record"); const Type *Ty = getTypeByID(Record[0]); - if (!isa(Ty)) + if (!Ty->isPointerTy()) return Error("Function not a pointer type!"); GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]), @@ -1932,7 +1932,7 @@ const Type *ReturnType = F->getReturnType(); if (Vs.size() > 1 || - (isa(ReturnType) && + (ReturnType->isStructTy() && (Vs.empty() || Vs[0]->getType() != ReturnType))) { Value *RV = UndefValue::get(ReturnType); for (unsigned i = 0, e = Vs.size(); i != e; ++i) { Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Tue Feb 16 05:11:14 2010 @@ -27,7 +27,7 @@ } static bool isIntegerValue(const std::pair &V) { - return isa(V.first->getType()); + return V.first->getType()->isIntegerTy(); } static bool CompareByFrequency(const std::pair(V->getType()) && "Unexpected operand type!"); + assert(V->getType()->isIntegerTy() && "Unexpected operand type!"); } while (1); } @@ -87,7 +87,7 @@ break; const Value *O = getUnderlyingObjectFromInt(cast(V)->getOperand(0)); // If that succeeded in finding a pointer, continue the search. - if (!isa(O->getType())) + if (!O->getType()->isPointerTy()) break; V = O; } while (1); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Feb 16 05:11:14 2010 @@ -1345,7 +1345,7 @@ } SDValue SelectionDAG::getSrcValue(const Value *V) { - assert((!V || isa(V->getType())) && + assert((!V || V->getType()->isPointerTy()) && "SrcValue is not a pointer?"); FoldingSetNodeID ID; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Feb 16 05:11:14 2010 @@ -680,7 +680,7 @@ getCurDebugLoc()); } - if (isa(C->getType()) || isa(C->getType())) { + if (C->getType()->isStructTy() || C->getType()->isArrayTy()) { assert((isa(C) || isa(C)) && "Unknown struct or array constant!"); @@ -2080,7 +2080,7 @@ void SelectionDAGBuilder::visitFSub(User &I) { // -0.0 - X --> fneg const Type *Ty = I.getType(); - if (isa(Ty)) { + if (Ty->isVectorTy()) { if (ConstantVector *CV = dyn_cast(I.getOperand(0))) { const VectorType *DestTy = cast(I.getType()); const Type *ElTy = DestTy->getElementType(); @@ -2117,7 +2117,7 @@ void SelectionDAGBuilder::visitShift(User &I, unsigned Opcode) { SDValue Op1 = getValue(I.getOperand(0)); SDValue Op2 = getValue(I.getOperand(1)); - if (!isa(I.getType()) && + if (!I.getType()->isVectorTy() && Op2.getValueType() != TLI.getShiftAmountTy()) { // If the operand is smaller than the shift count type, promote it. EVT PTy = TLI.getPointerTy(); @@ -4287,8 +4287,8 @@ // Check for a truly no-op bitcast. if (isa(U) && (U->getOperand(0)->getType() == U->getType() || - (isa(U->getOperand(0)->getType()) && - isa(U->getType())))) + (U->getOperand(0)->getType()->isPointerTy() && + U->getType()->isPointerTy()))) continue; // Otherwise it's not a true no-op. return false; @@ -4541,9 +4541,9 @@ return false; Value *LHS = I.getOperand(1), *RHS = I.getOperand(2); - if (!isa(LHS->getType()) || !isa(RHS->getType()) || - !isa(I.getOperand(3)->getType()) || - !isa(I.getType())) + if (!LHS->getType()->isPointerTy() || !RHS->getType()->isPointerTy() || + !I.getOperand(3)->getType()->isIntegerTy() || + !I.getType()->isIntegerTy()) return false; ConstantInt *Size = dyn_cast(I.getOperand(3)); Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Tue Feb 16 05:11:14 2010 @@ -344,7 +344,7 @@ } // FALLS THROUGH case 0: - if (!isa(FTy->getReturnType()) && + if (!FTy->getReturnType()->isIntegerTy() && !FTy->getReturnType()->isVoidTy()) { llvm_report_error("Invalid return type of main() supplied"); } @@ -614,7 +614,7 @@ GV.IntVal.doubleToBits(GV.DoubleVal); break; case Type::PointerTyID: - assert(isa(DestTy) && "Invalid bitcast"); + assert(DestTy->isPointerTy() && "Invalid bitcast"); break; // getConstantValue(Op0) above already converted it } return GV; Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp Tue Feb 16 05:11:14 2010 @@ -761,7 +761,7 @@ GenericValue Interpreter::executeGEPOperation(Value *Ptr, gep_type_iterator I, gep_type_iterator E, ExecutionContext &SF) { - assert(isa(Ptr->getType()) && + assert(Ptr->getType()->isPointerTy() && "Cannot getElementOffset of a nonpointer type!"); uint64_t Total = 0; @@ -1031,7 +1031,7 @@ ExecutionContext &SF) { uint32_t DBitWidth = cast(DstTy)->getBitWidth(); GenericValue Dest, Src = getOperandValue(SrcVal, SF); - assert(isa(SrcVal->getType()) && "Invalid PtrToInt instruction"); + assert(SrcVal->getType()->isPointerTy() && "Invalid PtrToInt instruction"); Dest.IntVal = APInt(DBitWidth, (intptr_t) Src.PointerVal); return Dest; @@ -1040,7 +1040,7 @@ GenericValue Interpreter::executeIntToPtrInst(Value *SrcVal, const Type *DstTy, ExecutionContext &SF) { GenericValue Dest, Src = getOperandValue(SrcVal, SF); - assert(isa(DstTy) && "Invalid PtrToInt instruction"); + assert(DstTy->isPointerTy() && "Invalid PtrToInt instruction"); uint32_t PtrSize = TD.getPointerSizeInBits(); if (PtrSize != Src.IntVal.getBitWidth()) @@ -1055,8 +1055,8 @@ const Type *SrcTy = SrcVal->getType(); GenericValue Dest, Src = getOperandValue(SrcVal, SF); - if (isa(DstTy)) { - assert(isa(SrcTy) && "Invalid BitCast"); + if (DstTy->isPointerTy()) { + assert(SrcTy->isPointerTy() && "Invalid BitCast"); Dest.PointerVal = Src.PointerVal; } else if (DstTy->isIntegerTy()) { if (SrcTy->isFloatTy()) { Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Tue Feb 16 05:11:14 2010 @@ -415,8 +415,8 @@ switch (ArgValues.size()) { case 3: if (FTy->getParamType(0)->isIntegerTy(32) && - isa(FTy->getParamType(1)) && - isa(FTy->getParamType(2))) { + FTy->getParamType(1)->isPointerTy() && + FTy->getParamType(2)->isPointerTy()) { int (*PF)(int, char **, const char **) = (int(*)(int, char **, const char **))(intptr_t)FPtr; @@ -430,7 +430,7 @@ break; case 2: if (FTy->getParamType(0)->isIntegerTy(32) && - isa(FTy->getParamType(1))) { + FTy->getParamType(1)->isPointerTy()) { int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr; // Call the function. Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Feb 16 05:11:14 2010 @@ -385,8 +385,8 @@ // If this isn't a struct or array type, remove it from our set of types // to name. This simplifies emission later. - if (!isa(I->second) && !isa(I->second) && - !isa(I->second)) { + if (!I->second->isStructTy() && !isa(I->second) && + !I->second->isArrayTy()) { TST.remove(I); } else { // If this is not used, remove it from the symbol table. @@ -405,7 +405,7 @@ unsigned RenameCounter = 0; for (std::set::const_iterator I = UT.begin(), E = UT.end(); I != E; ++I) - if (isa(*I) || isa(*I)) { + if ((*I)->isStructTy() || (*I)->isArrayTy()) { while (M.addTypeName("unnamed"+utostr(RenameCounter), *I)) ++RenameCounter; Changed = true; @@ -470,7 +470,7 @@ FunctionInnards << ", "; const Type *ArgTy = *I; if (PAL.paramHasAttr(Idx, Attribute::ByVal)) { - assert(isa(ArgTy)); + assert(ArgTy->isPointerTy()); ArgTy = cast(ArgTy)->getElementType(); } printType(FunctionInnards, ArgTy, @@ -493,7 +493,7 @@ CWriter::printSimpleType(formatted_raw_ostream &Out, const Type *Ty, bool isSigned, const std::string &NameSoFar) { - assert((Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) && + assert((Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) && "Invalid type for printSimpleType"); switch (Ty->getTypeID()) { case Type::VoidTyID: return Out << "void " << NameSoFar; @@ -540,7 +540,7 @@ std::ostream & CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned, const std::string &NameSoFar) { - assert((Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) && + assert((Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) && "Invalid type for printSimpleType"); switch (Ty->getTypeID()) { case Type::VoidTyID: return Out << "void " << NameSoFar; @@ -591,7 +591,7 @@ const Type *Ty, bool isSigned, const std::string &NameSoFar, bool IgnoreName, const AttrListPtr &PAL) { - if (Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) { + if (Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) { printSimpleType(Out, Ty, isSigned, NameSoFar); return Out; } @@ -612,7 +612,7 @@ E = FTy->param_end(); I != E; ++I) { const Type *ArgTy = *I; if (PAL.paramHasAttr(Idx, Attribute::ByVal)) { - assert(isa(ArgTy)); + assert(ArgTy->isPointerTy()); ArgTy = cast(ArgTy)->getElementType(); } if (I != FTy->param_begin()) @@ -653,8 +653,8 @@ const PointerType *PTy = cast(Ty); std::string ptrName = "*" + NameSoFar; - if (isa(PTy->getElementType()) || - isa(PTy->getElementType())) + if (PTy->getElementType()->isArrayTy() || + PTy->getElementType()->isVectorTy()) ptrName = "(" + ptrName + ")"; if (!PAL.isEmpty()) @@ -694,7 +694,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty, bool isSigned, const std::string &NameSoFar, bool IgnoreName, const AttrListPtr &PAL) { - if (Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty)) { + if (Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) { printSimpleType(Out, Ty, isSigned, NameSoFar); return Out; } @@ -715,7 +715,7 @@ E = FTy->param_end(); I != E; ++I) { const Type *ArgTy = *I; if (PAL.paramHasAttr(Idx, Attribute::ByVal)) { - assert(isa(ArgTy)); + assert(ArgTy->isPointerTy()); ArgTy = cast(ArgTy)->getElementType(); } if (I != FTy->param_begin()) @@ -756,8 +756,8 @@ const PointerType *PTy = cast(Ty); std::string ptrName = "*" + NameSoFar; - if (isa(PTy->getElementType()) || - isa(PTy->getElementType())) + if (PTy->getElementType()->isArrayTy() || + PTy->getElementType()->isVectorTy()) ptrName = "(" + ptrName + ")"; if (!PAL.isEmpty()) @@ -1144,7 +1144,7 @@ Out << "(("; printType(Out, CPV->getType()); // sign doesn't matter Out << ")/*UNDEF*/"; - if (!isa(CPV->getType())) { + if (!CPV->getType()->isVectorTy()) { Out << "0)"; } else { Out << "{})"; @@ -1660,7 +1660,7 @@ // If the operand was a pointer, convert to a large integer type. const Type* OpTy = Operand->getType(); - if (isa(OpTy)) + if (OpTy->isPointerTy()) OpTy = TD->getIntPtrType(Operand->getContext()); Out << "(("; @@ -2102,10 +2102,10 @@ // complete. If the value is an aggregate, print out { 0 }, and let // the compiler figure out the rest of the zeros. Out << " = " ; - if (isa(I->getInitializer()->getType()) || - isa(I->getInitializer()->getType())) { + if (I->getInitializer()->getType()->isStructTy() || + I->getInitializer()->getType()->isVectorTy()) { Out << "{ 0 }"; - } else if (isa(I->getInitializer()->getType())) { + } else if (I->getInitializer()->getType()->isArrayTy()) { // As with structs and vectors, but with an extra set of braces // because arrays are wrapped in structs. Out << "{ { 0 } }"; @@ -2274,7 +2274,7 @@ // Out << "/* Structure contents */\n"; for (I = TST.begin(); I != End; ++I) - if (isa(I->second) || isa(I->second)) + if (I->second->isStructTy() || I->second->isArrayTy()) // Only print out used types! printContainedStructs(I->second, StructPrinted); } @@ -2287,7 +2287,7 @@ void CWriter::printContainedStructs(const Type *Ty, std::set &StructPrinted) { // Don't walk through pointers. - if (isa(Ty) || Ty->isPrimitiveType() || Ty->isIntegerTy()) + if (Ty->isPointerTy() || Ty->isPrimitiveType() || Ty->isIntegerTy()) return; // Print all contained types first. @@ -2295,7 +2295,7 @@ E = Ty->subtype_end(); I != E; ++I) printContainedStructs(*I, StructPrinted); - if (isa(Ty) || isa(Ty)) { + if (Ty->isStructTy() || Ty->isArrayTy()) { // Check to see if we have already printed this struct. if (StructPrinted.insert(Ty).second) { // Print structure type out. @@ -2383,7 +2383,7 @@ if (PrintedArg) FunctionInnards << ", "; const Type *ArgTy = *I; if (PAL.paramHasAttr(Idx, Attribute::ByVal)) { - assert(isa(ArgTy)); + assert(ArgTy->isPointerTy()); ArgTy = cast(ArgTy)->getElementType(); } printType(FunctionInnards, ArgTy, @@ -2714,7 +2714,7 @@ void CWriter::visitBinaryOperator(Instruction &I) { // binary instructions, shift instructions, setCond instructions. - assert(!isa(I.getType())); + assert(!I.getType()->isPointerTy()); // We must cast the results of binary operations which might be promoted. bool needsCast = false; @@ -3490,7 +3490,7 @@ // exposed, like a global, avoid emitting (&foo)[0], just emit foo instead. if (isAddressExposed(Ptr)) { writeOperandInternal(Ptr, Static); - } else if (I != E && isa(*I)) { + } else if (I != E && (*I)->isStructTy()) { // If we didn't already emit the first operand, see if we can print it as // P->f instead of "P[0].f" writeOperand(Ptr); @@ -3505,13 +3505,13 @@ } for (; I != E; ++I) { - if (isa(*I)) { + if ((*I)->isStructTy()) { Out << ".field" << cast(I.getOperand())->getZExtValue(); - } else if (isa(*I)) { + } else if ((*I)->isArrayTy()) { Out << ".array["; writeOperandWithCast(I.getOperand(), Instruction::GetElementPtr); Out << ']'; - } else if (!isa(*I)) { + } else if (!(*I)->isVectorTy()) { Out << '['; writeOperandWithCast(I.getOperand(), Instruction::GetElementPtr); Out << ']'; @@ -3669,7 +3669,7 @@ i != e; ++i) { const Type *IndexedTy = ExtractValueInst::getIndexedType(IVI.getOperand(0)->getType(), b, i+1); - if (isa(IndexedTy)) + if (IndexedTy->isArrayTy()) Out << ".array[" << *i << "]"; else Out << ".field" << *i; @@ -3690,7 +3690,7 @@ i != e; ++i) { const Type *IndexedTy = ExtractValueInst::getIndexedType(EVI.getOperand(0)->getType(), b, i+1); - if (isa(IndexedTy)) + if (IndexedTy->isArrayTy()) Out << ".array[" << *i << "]"; else Out << ".field" << *i; Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Tue Feb 16 05:11:14 2010 @@ -57,7 +57,7 @@ TypeSymbolTable& Table = M.getTypeSymbolTable(); std::set Types = getAnalysis().getTypes(); for (TypeSymbolTable::iterator I = Table.begin(), E = Table.end(); I!=E; ) { - if (!isa(I->second) && !isa(I->second)) + if (!I->second->isStructTy() && !isa(I->second)) Table.remove(I++); else { std::set::iterator T = Types.find(I->second); @@ -1459,7 +1459,7 @@ for (std::set::const_iterator UI = UsedTypes->begin(), UE = UsedTypes->end(); UI!=UE; ++UI) { const Type* Ty = *UI; - if (isa(Ty) || isa(Ty) || isa(Ty)) + if (Ty->isArrayTy() || Ty->isVectorTy() || Ty->isStructTy()) Name = getTypeName(Ty, false, true); // Type with no need to declare. else continue; Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Tue Feb 16 05:11:14 2010 @@ -580,7 +580,7 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices, unsigned NumIndices) const { const Type *Ty = ptrTy; - assert(isa(Ty) && "Illegal argument for getIndexedOffset()"); + assert(Ty->isPointerTy() && "Illegal argument for getIndexedOffset()"); uint64_t Result = 0; generic_gep_type_iterator Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Tue Feb 16 05:11:14 2010 @@ -124,7 +124,7 @@ unsigned ArgNo = 0; for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I, ++ArgNo) - if (isa(I->getType())) + if (I->getType()->isPointerTy()) PointerArgs.push_back(std::pair(I, ArgNo)); if (PointerArgs.empty()) return 0; @@ -673,7 +673,7 @@ IE = SI->end(); II != IE; ++II) { // Use i32 to index structs, and i64 for others (pointers/arrays). // This satisfies GEP constraints. - const Type *IdxTy = (isa(ElTy) ? + const Type *IdxTy = (ElTy->isStructTy() ? Type::getInt32Ty(F->getContext()) : Type::getInt64Ty(F->getContext())); Ops.push_back(ConstantInt::get(IdxTy, *II)); Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Tue Feb 16 05:11:14 2010 @@ -796,7 +796,7 @@ // Replace by null for now. Call->replaceAllUsesWith(Constant::getNullValue(Call->getType())); } else { - assert(isa(RetTy) && + assert(RetTy->isStructTy() && "Return type changed, but not into a void. The old return type" " must have been a struct!"); Instruction *InsertPt = Call; @@ -870,7 +870,7 @@ if (NFTy->getReturnType() == Type::getVoidTy(F->getContext())) { RetVal = 0; } else { - assert (isa(RetTy)); + assert (RetTy->isStructTy()); // The original return value was a struct, insert // extractvalue/insertvalue chains to extract only the values we need // to return and insert them into our new result. Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Tue Feb 16 05:11:14 2010 @@ -175,7 +175,7 @@ for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); CI != CE; ++CI) { Value *Arg = *CI; - if (isa(Arg->getType()) && !PointsToLocalMemory(Arg)) + if (Arg->getType()->isPointerTy() && !PointsToLocalMemory(Arg)) // Writes memory. Just give up. return false; } @@ -257,7 +257,7 @@ continue; for (Function::arg_iterator A = F->arg_begin(), E = F->arg_end(); A!=E; ++A) - if (isa(A->getType()) && !A->hasNoCaptureAttr() && + if (A->getType()->isPointerTy() && !A->hasNoCaptureAttr() && !PointerMayBeCaptured(A, true, /*StoreCaptures=*/false)) { A->addAttr(Attribute::NoCapture); ++NumNoCapture; @@ -362,7 +362,7 @@ // We annotate noalias return values, which are only applicable to // pointer types. - if (!isa(F->getReturnType())) + if (!F->getReturnType()->isPointerTy()) continue; if (!IsFunctionMallocLike(F, SCCNodes)) @@ -372,7 +372,7 @@ bool MadeChange = false; for (unsigned i = 0, e = SCC.size(); i != e; ++i) { Function *F = SCC[i]->getFunction(); - if (F->doesNotAlias(0) || !isa(F->getReturnType())) + if (F->doesNotAlias(0) || !F->getReturnType()->isPointerTy()) continue; F->setDoesNotAlias(0); Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Feb 16 05:11:14 2010 @@ -303,7 +303,7 @@ SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE); Changed |= CleanupConstantGlobalUsers(CE, SubInit); } else if (CE->getOpcode() == Instruction::BitCast && - isa(CE->getType())) { + CE->getType()->isPointerTy()) { // Pointer cast, delete any stores and memsets to the global. Changed |= CleanupConstantGlobalUsers(CE, 0); } @@ -431,7 +431,7 @@ else if (const VectorType *SubVectorTy = dyn_cast(*GEPI)) NumElements = SubVectorTy->getNumElements(); else { - assert(isa(*GEPI) && + assert((*GEPI)->isStructTy() && "Indexed GEP type is not array, vector, or struct!"); continue; } @@ -1556,7 +1556,7 @@ // only has one (non-null) value stored into it, then we can optimize any // users of the loaded value (often calls and loads) that would trap if the // value was null. - if (isa(GV->getInitializer()->getType()) && + if (GV->getInitializer()->getType()->isPointerTy() && GV->getInitializer()->isNullValue()) { if (Constant *SOVC = dyn_cast(StoredOnceVal)) { if (GV->getInitializer()->getType() != SOVC->getType()) @@ -1591,7 +1591,7 @@ // where v1 and v2 both require constant pool loads, a big loss. if (GVElType == Type::getInt1Ty(GV->getContext()) || GVElType->isFloatingPointTy() || - isa(GVElType) || isa(GVElType)) + GVElType->isPointerTy() || GVElType->isVectorTy()) return false; // Walk the use list of the global seeing if all the uses are load or store. @@ -2148,7 +2148,7 @@ Elts[CI->getZExtValue()] = EvaluateStoreInto(Elts[CI->getZExtValue()], Val, Addr, OpNo+1); - if (isa(Init->getType())) + if (Init->getType()->isArrayTy()) return ConstantArray::get(cast(InitTy), Elts); else return ConstantVector::get(&Elts[0], Elts.size()); Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Tue Feb 16 05:11:14 2010 @@ -1618,7 +1618,7 @@ // (A & (C0?-1:0)) | (B & ~(C0?-1:0)) -> C0 ? A : B, and commuted variants. // Don't do this for vector select idioms, the code generator doesn't handle // them well yet. - if (!isa(I.getType())) { + if (!I.getType()->isVectorTy()) { if (Instruction *Match = MatchSelectFromAndOr(A, B, C, D)) return Match; if (Instruction *Match = MatchSelectFromAndOr(B, A, D, C)) @@ -1755,7 +1755,7 @@ // purpose is to compute bits we don't care about. if (SimplifyDemandedInstructionBits(I)) return &I; - if (isa(I.getType())) + if (I.getType()->isVectorTy()) if (isa(Op1)) return ReplaceInstUsesWith(I, Op0); // X ^ <0,0> -> X Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Tue Feb 16 05:11:14 2010 @@ -831,7 +831,7 @@ const Type *OldRetTy = Caller->getType(); const Type *NewRetTy = FT->getReturnType(); - if (isa(NewRetTy)) + if (NewRetTy->isStructTy()) return false; // TODO: Handle multiple return values. // Check to see if we are changing the return type... @@ -839,9 +839,9 @@ if (Callee->isDeclaration() && // Conversion is ok if changing from one pointer type to another or from // a pointer to an integer of the same size. - !((isa(OldRetTy) || !TD || + !((OldRetTy->isPointerTy() || !TD || OldRetTy == TD->getIntPtrType(Caller->getContext())) && - (isa(NewRetTy) || !TD || + (NewRetTy->isPointerTy() || !TD || NewRetTy == TD->getIntPtrType(Caller->getContext())))) return false; // Cannot transform this return value. @@ -888,9 +888,9 @@ // Converting from one pointer type to another or between a pointer and an // integer of the same size is safe even if we do not have a body. bool isConvertible = ActTy == ParamTy || - (TD && ((isa(ParamTy) || + (TD && ((ParamTy->isPointerTy() || ParamTy == TD->getIntPtrType(Caller->getContext())) && - (isa(ActTy) || + (ActTy->isPointerTy() || ActTy == TD->getIntPtrType(Caller->getContext())))); if (Callee->isDeclaration() && !isConvertible) return false; } Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Tue Feb 16 05:11:14 2010 @@ -272,7 +272,7 @@ // If this is a vector sext from a compare, then we don't want to break the // idiom where each element of the extended vector is either zero or all ones. - if (opc == Instruction::SExt && isa(V) && isa(Ty)) + if (opc == Instruction::SExt && isa(V) && Ty->isVectorTy()) return false; return true; @@ -303,8 +303,8 @@ if (isa(Src)) { // We don't do this if this would create a PHI node with an illegal type if // it is currently legal. - if (!isa(Src->getType()) || - !isa(CI.getType()) || + if (!Src->getType()->isIntegerTy() || + !CI.getType()->isIntegerTy() || ShouldChangeType(CI.getType(), Src->getType())) if (Instruction *NV = FoldOpIntoPhi(CI)) return NV; @@ -436,7 +436,7 @@ // type. Only do this if the dest type is a simple type, don't convert the // expression tree to something weird like i93 unless the source is also // strange. - if ((isa(DestTy) || ShouldChangeType(SrcTy, DestTy)) && + if ((DestTy->isVectorTy() || ShouldChangeType(SrcTy, DestTy)) && CanEvaluateTruncated(Src, DestTy)) { // If this cast is a truncate, evaluting in a different type always @@ -728,7 +728,7 @@ // expression tree to something weird like i93 unless the source is also // strange. unsigned BitsToClear; - if ((isa(DestTy) || ShouldChangeType(SrcTy, DestTy)) && + if ((DestTy->isVectorTy() || ShouldChangeType(SrcTy, DestTy)) && CanEvaluateZExtd(Src, DestTy, BitsToClear)) { assert(BitsToClear < SrcTy->getScalarSizeInBits() && "Unreasonable BitsToClear"); @@ -936,7 +936,7 @@ // type. Only do this if the dest type is a simple type, don't convert the // expression tree to something weird like i93 unless the source is also // strange. - if ((isa(DestTy) || ShouldChangeType(SrcTy, DestTy)) && + if ((DestTy->isVectorTy() || ShouldChangeType(SrcTy, DestTy)) && CanEvaluateSExtd(Src, DestTy)) { // Okay, we can transform this! Insert the new expression now. DEBUG(dbgs() << "ICE: EvaluateInDifferentType converting expression type" @@ -1289,7 +1289,7 @@ Constant::getNullValue(Type::getInt32Ty(CI.getContext())); unsigned NumZeros = 0; while (SrcElTy != DstElTy && - isa(SrcElTy) && !isa(SrcElTy) && + isa(SrcElTy) && !SrcElTy->isPointerTy() && SrcElTy->getNumContainedTypes() /* not "{}" */) { SrcElTy = cast(SrcElTy)->getTypeAtIndex(ZeroUInt); ++NumZeros; @@ -1304,7 +1304,7 @@ } if (const VectorType *DestVTy = dyn_cast(DestTy)) { - if (DestVTy->getNumElements() == 1 && !isa(SrcTy)) { + if (DestVTy->getNumElements() == 1 && !SrcTy->isVectorTy()) { Value *Elem = Builder->CreateBitCast(Src, DestVTy->getElementType()); return InsertElementInst::Create(UndefValue::get(DestTy), Elem, Constant::getNullValue(Type::getInt32Ty(CI.getContext()))); @@ -1313,7 +1313,7 @@ } if (const VectorType *SrcVTy = dyn_cast(SrcTy)) { - if (SrcVTy->getNumElements() == 1 && !isa(DestTy)) { + if (SrcVTy->getNumElements() == 1 && !DestTy->isVectorTy()) { Value *Elem = Builder->CreateExtractElement(Src, Constant::getNullValue(Type::getInt32Ty(CI.getContext()))); @@ -1324,7 +1324,7 @@ if (ShuffleVectorInst *SVI = dyn_cast(Src)) { // Okay, we have (bitcast (shuffle ..)). Check to see if this is // a bitconvert to a vector with the same # elts. - if (SVI->hasOneUse() && isa(DestTy) && + if (SVI->hasOneUse() && DestTy->isVectorTy() && cast(DestTy)->getNumElements() == SVI->getType()->getNumElements() && SVI->getType()->getNumElements() == @@ -1346,7 +1346,7 @@ } } - if (isa(SrcTy)) + if (SrcTy->isPointerTy()) return commonPointerCastTransforms(CI); return commonCastTransforms(CI); } Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Feb 16 05:11:14 2010 @@ -1988,7 +1988,7 @@ // values. If the ptr->ptr cast can be stripped off both arguments, we do so // now. if (BitCastInst *CI = dyn_cast(Op0)) { - if (isa(Op0->getType()) && + if (Op0->getType()->isPointerTy() && (isa(Op1) || isa(Op1))) { // We keep moving the cast from the left operand over to the right // operand, where it can often be eliminated completely. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Tue Feb 16 05:11:14 2010 @@ -87,8 +87,8 @@ const Type *SrcPTy = SrcTy->getElementType(); - if (DestPTy->isIntegerTy() || isa(DestPTy) || - isa(DestPTy)) { + if (DestPTy->isIntegerTy() || DestPTy->isPointerTy() || + DestPTy->isVectorTy()) { // If the source is an array, the code below will not succeed. Check to // see if a trivial 'gep P, 0, 0' will help matters. Only do this for // constants. @@ -104,11 +104,11 @@ } if (IC.getTargetData() && - (SrcPTy->isIntegerTy() || isa(SrcPTy) || - isa(SrcPTy)) && + (SrcPTy->isIntegerTy() || SrcPTy->isPointerTy() || + SrcPTy->isVectorTy()) && // Do not allow turning this into a load of an integer, which is then // casted to a pointer, this pessimizes pointer analysis a lot. - (isa(SrcPTy) == isa(LI.getType())) && + (SrcPTy->isPointerTy() == LI.getType()->isPointerTy()) && IC.getTargetData()->getTypeSizeInBits(SrcPTy) == IC.getTargetData()->getTypeSizeInBits(DestPTy)) { @@ -243,7 +243,7 @@ const Type *SrcPTy = SrcTy->getElementType(); - if (!DestPTy->isIntegerTy() && !isa(DestPTy)) + if (!DestPTy->isIntegerTy() && !DestPTy->isPointerTy()) return 0; /// NewGEPIndices - If SrcPTy is an aggregate type, we can emit a "noop gep" @@ -255,7 +255,7 @@ // If the source is an array, the code below will not succeed. Check to // see if a trivial 'gep P, 0, 0' will help matters. Only do this for // constants. - if (isa(SrcPTy) || isa(SrcPTy)) { + if (SrcPTy->isArrayTy() || SrcPTy->isStructTy()) { // Index through pointer. Constant *Zero = Constant::getNullValue(Type::getInt32Ty(SI.getContext())); NewGEPIndices.push_back(Zero); @@ -277,7 +277,7 @@ SrcTy = PointerType::get(SrcPTy, SrcTy->getAddressSpace()); } - if (!SrcPTy->isIntegerTy() && !isa(SrcPTy)) + if (!SrcPTy->isIntegerTy() && !SrcPTy->isPointerTy()) return 0; // If the pointers point into different address spaces or if they point to @@ -297,11 +297,11 @@ Instruction::CastOps opcode = Instruction::BitCast; const Type* CastSrcTy = SIOp0->getType(); const Type* CastDstTy = SrcPTy; - if (isa(CastDstTy)) { + if (CastDstTy->isPointerTy()) { if (CastSrcTy->isIntegerTy()) opcode = Instruction::IntToPtr; - } else if (isa(CastDstTy)) { - if (isa(SIOp0->getType())) + } else if (CastDstTy->isIntegerTy()) { + if (SIOp0->getType()->isPointerTy()) opcode = Instruction::PtrToInt; } @@ -413,7 +413,7 @@ // Don't count debug info directives, lest they affect codegen, // and we skip pointer-to-pointer bitcasts, which are NOPs. if (isa(BBI) || - (isa(BBI) && isa(BBI->getType()))) { + (isa(BBI) && BBI->getType()->isPointerTy())) { ScanInsts++; continue; } @@ -483,7 +483,7 @@ do { ++BBI; } while (isa(BBI) || - (isa(BBI) && isa(BBI->getType()))); + (isa(BBI) && BBI->getType()->isPointerTy())); if (BranchInst *BI = dyn_cast(BBI)) if (BI->isUnconditional()) if (SimplifyStoreAtEndOfBlock(SI)) @@ -544,7 +544,7 @@ --BBI; // Skip over debugging info. while (isa(BBI) || - (isa(BBI) && isa(BBI->getType()))) { + (isa(BBI) && BBI->getType()->isPointerTy())) { if (BBI==OtherBB->begin()) return false; --BBI; Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Tue Feb 16 05:11:14 2010 @@ -76,7 +76,7 @@ return BinaryOperator::CreateShl(Op0, ConstantInt::get(Op0->getType(), Val.logBase2())); } - } else if (isa(Op1C->getType())) { + } else if (Op1C->getType()->isVectorTy()) { if (Op1C->isNullValue()) return ReplaceInstUsesWith(I, Op1C); @@ -173,7 +173,7 @@ // If one of the operands of the multiply is a cast from a boolean value, then // we know the bool is either zero or one, so this is a 'masking' multiply. // X * Y (where Y is 0 or 1) -> X & (0-Y) - if (!isa(I.getType())) { + if (!I.getType()->isVectorTy()) { // -2 is "-1 << 1" so it is all bits set except the low one. APInt Negative2(I.getType()->getPrimitiveSizeInBits(), (uint64_t)-2, true); @@ -204,7 +204,7 @@ // ANSI says we can drop signals, so we can do this anyway." (from GCC) if (Op1F->isExactlyValue(1.0)) return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0' - } else if (isa(Op1C->getType())) { + } else if (Op1C->getType()->isVectorTy()) { if (ConstantVector *Op1V = dyn_cast(Op1C)) { // As above, vector X*splat(1.0) -> X in all defined cases. if (Constant *Splat = Op1V->getSplatValue()) { Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp Tue Feb 16 05:11:14 2010 @@ -371,7 +371,7 @@ // Be careful about transforming integer PHIs. We don't want to pessimize // the code by turning an i32 into an i1293. - if (isa(PN.getType()) && isa(CastSrcTy)) { + if (PN.getType()->isIntegerTy() && CastSrcTy->isIntegerTy()) { if (!ShouldChangeType(PN.getType(), CastSrcTy)) return 0; } @@ -832,7 +832,7 @@ // it is only used by trunc or trunc(lshr) operations. If so, we split the // PHI into the various pieces being extracted. This sort of thing is // introduced when SROA promotes an aggregate to a single large integer type. - if (isa(PN.getType()) && TD && + if (PN.getType()->isIntegerTy() && TD && !TD->isLegalInteger(PN.getType()->getPrimitiveSizeInBits())) if (Instruction *Res = SliceUpIllegalIntegerPHI(PN)) return Res; Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp Tue Feb 16 05:11:14 2010 @@ -104,7 +104,7 @@ assert(Depth <= 6 && "Limit Search Depth"); uint32_t BitWidth = DemandedMask.getBitWidth(); const Type *VTy = V->getType(); - assert((TD || !isa(VTy)) && + assert((TD || !VTy->isPointerTy()) && "SimplifyDemandedBits needs to know bit widths!"); assert((!TD || TD->getTypeSizeInBits(VTy->getScalarType()) == BitWidth) && (!VTy->isIntOrIntVectorTy() || @@ -413,7 +413,7 @@ } else // Don't touch a scalar-to-vector bitcast. return 0; - } else if (isa(I->getOperand(0)->getType())) + } else if (I->getOperand(0)->getType()->isVectorTy()) // Don't touch a vector-to-scalar bitcast. return 0; Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Tue Feb 16 05:11:14 2010 @@ -78,7 +78,7 @@ /// value is already around as a register, for example if it were inserted then /// extracted from the vector. static Value *FindScalarElement(Value *V, unsigned EltNo) { - assert(isa(V->getType()) && "Not looking at a vector?"); + assert(V->getType()->isVectorTy() && "Not looking at a vector?"); const VectorType *PTy = cast(V->getType()); unsigned Width = PTy->getNumElements(); if (EltNo >= Width) // Out of range access. @@ -322,7 +322,7 @@ /// that computes V and the LHS value of the shuffle. static Value *CollectShuffleElements(Value *V, std::vector &Mask, Value *&RHS) { - assert(isa(V->getType()) && + assert(V->getType()->isVectorTy() && (RHS == 0 || V->getType() == RHS->getType()) && "Invalid shuffle!"); unsigned NumElts = cast(V->getType())->getNumElements(); Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Tue Feb 16 05:11:14 2010 @@ -73,7 +73,7 @@ /// from 'From' to 'To'. We don't want to convert from a legal to an illegal /// type for example, or from a smaller to a larger illegal type. bool InstCombiner::ShouldChangeType(const Type *From, const Type *To) const { - assert(isa(From) && isa(To)); + assert(From->isIntegerTy() && To->isIntegerTy()); // If we don't have TD, we don't know if the source/dest are legal. if (!TD) return false; @@ -478,7 +478,7 @@ bool EndsWithSequential = false; for (gep_type_iterator I = gep_type_begin(*Src), E = gep_type_end(*Src); I != E; ++I) - EndsWithSequential = !isa(*I); + EndsWithSequential = !(*I)->isStructTy(); // Can we combine the two pointer arithmetics offsets? if (EndsWithSequential) { @@ -578,7 +578,7 @@ // into: %t1 = getelementptr [2 x i32]* %str, i32 0, i32 %V; bitcast const Type *SrcElTy = StrippedPtrTy->getElementType(); const Type *ResElTy=cast(PtrOp->getType())->getElementType(); - if (TD && isa(SrcElTy) && + if (TD && SrcElTy->isArrayTy() && TD->getTypeAllocSize(cast(SrcElTy)->getElementType()) == TD->getTypeAllocSize(ResElTy)) { Value *Idx[2]; @@ -596,7 +596,7 @@ // (where tmp = 8*tmp2) into: // getelementptr [100 x double]* %arr, i32 0, i32 %tmp2; bitcast - if (TD && isa(SrcElTy) && ResElTy->isIntegerTy(8)) { + if (TD && SrcElTy->isArrayTy() && ResElTy->isIntegerTy(8)) { uint64_t ArrayEltSize = TD->getTypeAllocSize(cast(SrcElTy)->getElementType()); Modified: llvm/trunk/lib/Transforms/Scalar/ABCD.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ABCD.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ABCD.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ABCD.cpp Tue Feb 16 05:11:14 2010 @@ -505,7 +505,7 @@ continue; ICmpInst *ICI = dyn_cast(TI->getOperand(0)); - if (!ICI || !isa(ICI->getOperand(0)->getType())) + if (!ICI || !ICI->getOperand(0)->getType()->isIntegerTy()) continue; createConstraintCmpInst(ICI, TI); @@ -713,7 +713,7 @@ Value *V_op1 = ICI->getOperand(0); Value *V_op2 = ICI->getOperand(1); - if (!isa(V_op1->getType())) + if (!V_op1->getType()->isIntegerTy()) return; Instruction *I_op1 = dyn_cast(V_op1); Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Feb 16 05:11:14 2010 @@ -612,7 +612,7 @@ // we'd end up sinking both muls. if (AddrMode.BaseReg) { Value *V = AddrMode.BaseReg; - if (isa(V->getType())) + if (V->getType()->isPointerTy()) V = new PtrToIntInst(V, IntPtrTy, "sunkaddr", InsertPt); if (V->getType() != IntPtrTy) V = CastInst::CreateIntegerCast(V, IntPtrTy, /*isSigned=*/true, @@ -625,7 +625,7 @@ Value *V = AddrMode.ScaledReg; if (V->getType() == IntPtrTy) { // done. - } else if (isa(V->getType())) { + } else if (V->getType()->isPointerTy()) { V = new PtrToIntInst(V, IntPtrTy, "sunkaddr", InsertPt); } else if (cast(IntPtrTy)->getBitWidth() < cast(V->getType())->getBitWidth()) { Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Feb 16 05:11:14 2010 @@ -836,9 +836,9 @@ const TargetData &TD) { // If the loaded or stored value is an first class array or struct, don't try // to transform them. We need to be able to bitcast to integer. - if (isa(LoadTy) || isa(LoadTy) || - isa(StoredVal->getType()) || - isa(StoredVal->getType())) + if (LoadTy->isStructTy() || LoadTy->isArrayTy() || + StoredVal->getType()->isStructTy() || + StoredVal->getType()->isArrayTy()) return false; // The store has to be at least as big as the load. @@ -870,26 +870,26 @@ // If the store and reload are the same size, we can always reuse it. if (StoreSize == LoadSize) { - if (isa(StoredValTy) && isa(LoadedTy)) { + if (StoredValTy->isPointerTy() && LoadedTy->isPointerTy()) { // Pointer to Pointer -> use bitcast. return new BitCastInst(StoredVal, LoadedTy, "", InsertPt); } // Convert source pointers to integers, which can be bitcast. - if (isa(StoredValTy)) { + if (StoredValTy->isPointerTy()) { StoredValTy = TD.getIntPtrType(StoredValTy->getContext()); StoredVal = new PtrToIntInst(StoredVal, StoredValTy, "", InsertPt); } const Type *TypeToCastTo = LoadedTy; - if (isa(TypeToCastTo)) + if (TypeToCastTo->isPointerTy()) TypeToCastTo = TD.getIntPtrType(StoredValTy->getContext()); if (StoredValTy != TypeToCastTo) StoredVal = new BitCastInst(StoredVal, TypeToCastTo, "", InsertPt); // Cast to pointer if the load needs a pointer type. - if (isa(LoadedTy)) + if (LoadedTy->isPointerTy()) StoredVal = new IntToPtrInst(StoredVal, LoadedTy, "", InsertPt); return StoredVal; @@ -901,13 +901,13 @@ assert(StoreSize >= LoadSize && "CanCoerceMustAliasedValueToLoad fail"); // Convert source pointers to integers, which can be manipulated. - if (isa(StoredValTy)) { + if (StoredValTy->isPointerTy()) { StoredValTy = TD.getIntPtrType(StoredValTy->getContext()); StoredVal = new PtrToIntInst(StoredVal, StoredValTy, "", InsertPt); } // Convert vectors and fp to integer, which can be manipulated. - if (!isa(StoredValTy)) { + if (!StoredValTy->isIntegerTy()) { StoredValTy = IntegerType::get(StoredValTy->getContext(), StoreSize); StoredVal = new BitCastInst(StoredVal, StoredValTy, "", InsertPt); } @@ -927,7 +927,7 @@ return StoredVal; // If the result is a pointer, inttoptr. - if (isa(LoadedTy)) + if (LoadedTy->isPointerTy()) return new IntToPtrInst(StoredVal, LoadedTy, "inttoptr", InsertPt); // Otherwise, bitcast. @@ -989,7 +989,7 @@ const TargetData &TD) { // If the loaded or stored value is an first class array or struct, don't try // to transform them. We need to be able to bitcast to integer. - if (isa(LoadTy) || isa(LoadTy)) + if (LoadTy->isStructTy() || LoadTy->isArrayTy()) return -1; int64_t StoreOffset = 0, LoadOffset = 0; @@ -1064,8 +1064,8 @@ StoreInst *DepSI, const TargetData &TD) { // Cannot handle reading from store of first-class aggregate yet. - if (isa(DepSI->getOperand(0)->getType()) || - isa(DepSI->getOperand(0)->getType())) + if (DepSI->getOperand(0)->getType()->isStructTy() || + DepSI->getOperand(0)->getType()->isArrayTy()) return -1; Value *StorePtr = DepSI->getPointerOperand(); @@ -1136,9 +1136,9 @@ // Compute which bits of the stored value are being used by the load. Convert // to an integer type to start with. - if (isa(SrcVal->getType())) + if (SrcVal->getType()->isPointerTy()) SrcVal = Builder.CreatePtrToInt(SrcVal, TD.getIntPtrType(Ctx), "tmp"); - if (!isa(SrcVal->getType())) + if (!SrcVal->getType()->isIntegerTy()) SrcVal = Builder.CreateBitCast(SrcVal, IntegerType::get(Ctx, StoreSize*8), "tmp"); @@ -1323,7 +1323,7 @@ Value *V = SSAUpdate.GetValueInMiddleOfBlock(LI->getParent()); // If new PHI nodes were created, notify alias analysis. - if (isa(V->getType())) + if (V->getType()->isPointerTy()) for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i) AA->copyValue(LI, NewPHIs[i]); @@ -1491,7 +1491,7 @@ if (isa(V)) V->takeName(LI); - if (isa(V->getType())) + if (V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); toErase.push_back(LI); NumGVNLoad++; @@ -1705,7 +1705,7 @@ LI->replaceAllUsesWith(V); if (isa(V)) V->takeName(LI); - if (isa(V->getType())) + if (V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); toErase.push_back(LI); NumPRELoad++; @@ -1765,7 +1765,7 @@ // Replace the load! L->replaceAllUsesWith(AvailVal); - if (isa(AvailVal->getType())) + if (AvailVal->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(AvailVal); toErase.push_back(L); NumGVNLoad++; @@ -1810,7 +1810,7 @@ // Remove it! L->replaceAllUsesWith(StoredVal); - if (isa(StoredVal->getType())) + if (StoredVal->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(StoredVal); toErase.push_back(L); NumGVNLoad++; @@ -1839,7 +1839,7 @@ // Remove it! L->replaceAllUsesWith(AvailableVal); - if (isa(DepLI->getType())) + if (DepLI->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(DepLI); toErase.push_back(L); NumGVNLoad++; @@ -1943,7 +1943,7 @@ if (constVal) { p->replaceAllUsesWith(constVal); - if (MD && isa(constVal->getType())) + if (MD && constVal->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(constVal); VN.erase(p); @@ -1964,7 +1964,7 @@ // Remove it! VN.erase(I); I->replaceAllUsesWith(repl); - if (MD && isa(repl->getType())) + if (MD && repl->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(repl); toErase.push_back(I); return true; @@ -2204,7 +2204,7 @@ localAvail[CurrentBlock]->table[ValNo] = Phi; CurInst->replaceAllUsesWith(Phi); - if (MD && isa(Phi->getType())) + if (MD && Phi->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(Phi); VN.erase(CurInst); Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Feb 16 05:11:14 2010 @@ -248,8 +248,8 @@ Value *InVal = PN->getIncomingValue(i); if (!isa(InVal) || // SCEV only supports integer expressions for now. - (!isa(InVal->getType()) && - !isa(InVal->getType()))) + (!InVal->getType()->isIntegerTy() && + !InVal->getType()->isPointerTy())) continue; // If this pred is for a subloop, not L itself, skip it. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Feb 16 05:11:14 2010 @@ -201,7 +201,7 @@ if (isa(I)) continue; // If this is a pointer->pointer bitcast, it is free. - if (isa(I) && isa(I->getType())) + if (isa(I) && I->getType()->isPointerTy()) continue; // All other instructions count for at least one unit. @@ -214,7 +214,7 @@ if (const CallInst *CI = dyn_cast(I)) { if (!isa(CI)) Size += 3; - else if (!isa(CI->getType())) + else if (!CI->getType()->isVectorTy()) Size += 1; } } Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Tue Feb 16 05:11:14 2010 @@ -678,7 +678,7 @@ // If we are promoting a pointer value, update alias information for the // inserted load. Value *LoadValue = 0; - if (isa(cast(Ptr->getType())->getElementType())) { + if (cast(Ptr->getType())->getElementType()->isPointerTy()) { // Locate a load or store through the pointer, and assign the same value // to LI as we are loading or storing. Since we know that the value is // stored in this loop, this will always succeed. @@ -751,7 +751,7 @@ LoadInst *LI = new LoadInst(PromotedValues[i].first, "", InsertPos); // If this is a pointer type, update alias info appropriately. - if (isa(LI->getType())) + if (LI->getType()->isPointerTy()) CurAST->copyValue(PointerValueNumbers[PVN++], LI); // Store into the memory we promoted. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Feb 16 05:11:14 2010 @@ -925,7 +925,7 @@ case ICmpZero: OS << "ICmpZero"; break; case Address: OS << "Address of "; - if (isa(AccessTy)) + if (AccessTy->isPointerTy()) OS << "pointer"; // the full pointer type could be really verbose else OS << *AccessTy; Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Feb 16 05:11:14 2010 @@ -170,7 +170,7 @@ /// Otherwise, return null. static Value *FindLIVLoopCondition(Value *Cond, Loop *L, bool &Changed) { // We can never unswitch on vector conditions. - if (isa(Cond->getType())) + if (Cond->getType()->isVectorTy()) return 0; // Constants should be folded, not unswitched on! Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Tue Feb 16 05:11:14 2010 @@ -930,7 +930,7 @@ // Reject cases where it is pointless to do this. if (!isa(BI) || BI->getType()->isFloatingPointTy() || - isa(BI->getType())) + BI->getType()->isVectorTy()) continue; // Floating point ops are not associative. // Do not reassociate boolean (i1) expressions. We want to preserve the Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Tue Feb 16 05:11:14 2010 @@ -295,7 +295,7 @@ } void markOverdefined(Value *V) { - assert(!isa(V->getType()) && "Should use other method"); + assert(!V->getType()->isStructTy() && "Should use other method"); markOverdefined(ValueState[V], V); } @@ -321,12 +321,12 @@ } void markConstant(Value *V, Constant *C) { - assert(!isa(V->getType()) && "Should use other method"); + assert(!V->getType()->isStructTy() && "Should use other method"); markConstant(ValueState[V], V, C); } void markForcedConstant(Value *V, Constant *C) { - assert(!isa(V->getType()) && "Should use other method"); + assert(!V->getType()->isStructTy() && "Should use other method"); ValueState[V].markForcedConstant(C); DEBUG(dbgs() << "markForcedConstant: " << *C << ": " << *V << '\n'); InstWorkList.push_back(V); @@ -360,7 +360,7 @@ } void mergeInValue(Value *V, LatticeVal MergeWithV) { - assert(!isa(V->getType()) && "Should use other method"); + assert(!V->getType()->isStructTy() && "Should use other method"); mergeInValue(ValueState[V], V, MergeWithV); } @@ -369,7 +369,7 @@ /// value. This function handles the case when the value hasn't been seen yet /// by properly seeding constants etc. LatticeVal &getValueState(Value *V) { - assert(!isa(V->getType()) && "Should use getStructValueState"); + assert(!V->getType()->isStructTy() && "Should use getStructValueState"); std::pair::iterator, bool> I = ValueState.insert(std::make_pair(V, LatticeVal())); @@ -392,7 +392,7 @@ /// value/field pair. This function handles the case when the value hasn't /// been seen yet by properly seeding constants etc. LatticeVal &getStructValueState(Value *V, unsigned i) { - assert(isa(V->getType()) && "Should use getValueState"); + assert(V->getType()->isStructTy() && "Should use getValueState"); assert(i < cast(V->getType())->getNumElements() && "Invalid element #"); @@ -666,7 +666,7 @@ void SCCPSolver::visitPHINode(PHINode &PN) { // If this PN returns a struct, just mark the result overdefined. // TODO: We could do a lot better than this if code actually uses this. - if (isa(PN.getType())) + if (PN.getType()->isStructTy()) return markAnythingOverdefined(&PN); if (getValueState(&PN).isOverdefined()) { @@ -742,7 +742,7 @@ Value *ResultOp = I.getOperand(0); // If we are tracking the return value of this function, merge it in. - if (!TrackedRetVals.empty() && !isa(ResultOp->getType())) { + if (!TrackedRetVals.empty() && !ResultOp->getType()->isStructTy()) { DenseMap::iterator TFRVI = TrackedRetVals.find(F); if (TFRVI != TrackedRetVals.end()) { @@ -787,7 +787,7 @@ void SCCPSolver::visitExtractValueInst(ExtractValueInst &EVI) { // If this returns a struct, mark all elements over defined, we don't track // structs in structs. - if (isa(EVI.getType())) + if (EVI.getType()->isStructTy()) return markAnythingOverdefined(&EVI); // If this is extracting from more than one level of struct, we don't know. @@ -795,7 +795,7 @@ return markOverdefined(&EVI); Value *AggVal = EVI.getAggregateOperand(); - if (isa(AggVal->getType())) { + if (AggVal->getType()->isStructTy()) { unsigned i = *EVI.idx_begin(); LatticeVal EltVal = getStructValueState(AggVal, i); mergeInValue(getValueState(&EVI), &EVI, EltVal); @@ -828,7 +828,7 @@ } Value *Val = IVI.getInsertedValueOperand(); - if (isa(Val->getType())) + if (Val->getType()->isStructTy()) // We don't track structs in structs. markOverdefined(getStructValueState(&IVI, i), &IVI); else { @@ -841,7 +841,7 @@ void SCCPSolver::visitSelectInst(SelectInst &I) { // If this select returns a struct, just mark the result overdefined. // TODO: We could do a lot better than this if code actually uses this. - if (isa(I.getType())) + if (I.getType()->isStructTy()) return markAnythingOverdefined(&I); LatticeVal CondValue = getValueState(I.getCondition()); @@ -1166,7 +1166,7 @@ void SCCPSolver::visitStoreInst(StoreInst &SI) { // If this store is of a struct, ignore it. - if (isa(SI.getOperand(0)->getType())) + if (SI.getOperand(0)->getType()->isStructTy()) return; if (TrackedGlobals.empty() || !isa(SI.getOperand(1))) @@ -1187,7 +1187,7 @@ // global, we can replace the load with the loaded constant value! void SCCPSolver::visitLoadInst(LoadInst &I) { // If this load is of a struct, just mark the result overdefined. - if (isa(I.getType())) + if (I.getType()->isStructTy()) return markAnythingOverdefined(&I); LatticeVal PtrVal = getValueState(I.getOperand(0)); @@ -1241,7 +1241,7 @@ // Otherwise, if we have a single return value case, and if the function is // a declaration, maybe we can constant fold it. - if (F && F->isDeclaration() && !isa(I->getType()) && + if (F && F->isDeclaration() && !I->getType()->isStructTy() && canConstantFoldCallTo(F)) { SmallVector Operands; @@ -1352,7 +1352,7 @@ // since all of its users will have already been marked as overdefined. // Update all of the users of this instruction's value. // - if (isa(I->getType()) || !getValueState(I).isOverdefined()) + if (I->getType()->isStructTy() || !getValueState(I).isOverdefined()) for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) if (Instruction *I = dyn_cast(*UI)) @@ -1418,7 +1418,7 @@ if (!LV.isUndefined()) continue; // No instructions using structs need disambiguation. - if (isa(I->getOperand(0)->getType())) + if (I->getOperand(0)->getType()->isStructTy()) continue; // Get the lattice values of the first two operands for use below. @@ -1426,7 +1426,7 @@ LatticeVal Op1LV; if (I->getNumOperands() == 2) { // No instructions using structs need disambiguation. - if (isa(I->getOperand(1)->getType())) + if (I->getOperand(1)->getType()->isStructTy()) continue; // If this is a two-operand instruction, and if both operands are @@ -1656,7 +1656,7 @@ continue; // TODO: Reconstruct structs from their elements. - if (isa(Inst->getType())) + if (Inst->getType()->isStructTy()) continue; LatticeVal IV = Solver.getLatticeValueFor(Inst); @@ -1792,7 +1792,7 @@ if (Solver.isBlockExecutable(F->begin())) { for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI) { - if (AI->use_empty() || isa(AI->getType())) continue; + if (AI->use_empty() || AI->getType()->isStructTy()) continue; // TODO: Could use getStructLatticeValueFor to find out if the entire // result is a constant and replace it entirely if so. @@ -1835,7 +1835,7 @@ for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) { Instruction *Inst = BI++; - if (Inst->getType()->isVoidTy() || isa(Inst->getType())) + if (Inst->getType()->isVoidTy() || Inst->getType()->isStructTy()) continue; // TODO: Could use getStructLatticeValueFor to find out if the entire Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Feb 16 05:11:14 2010 @@ -302,7 +302,7 @@ // random stuff that doesn't use vectors (e.g. <9 x double>) because then // we just get a lot of insert/extracts. If at least one vector is // involved, then we probably really do have a union of vector/array. - if (VectorTy && isa(VectorTy) && HadAVector) { + if (VectorTy && VectorTy->isVectorTy() && HadAVector) { DEBUG(dbgs() << "CONVERT TO VECTOR: " << *AI << "\n TYPE = " << *VectorTy << '\n'); @@ -449,7 +449,7 @@ // into. for (; GEPIt != E; ++GEPIt) { // Ignore struct elements, no extra checking needed for these. - if (isa(*GEPIt)) + if ((*GEPIt)->isStructTy()) continue; ConstantInt *IdxVal = dyn_cast(GEPIt.getOperand()); @@ -480,7 +480,7 @@ // (which are essentially the same as the MemIntrinsics, especially with // regard to copying padding between elements), or references using the // aggregate type of the alloca. - if (!MemOpType || isa(MemOpType) || UsesAggregateType) { + if (!MemOpType || MemOpType->isIntegerTy() || UsesAggregateType) { if (!UsesAggregateType) { if (isStore) Info.isMemCpyDst = true; @@ -565,7 +565,7 @@ } LI->replaceAllUsesWith(Insert); DeadInsts.push_back(LI); - } else if (isa(LIType) && + } else if (LIType->isIntegerTy() && TD->getTypeAllocSize(LIType) == TD->getTypeAllocSize(AI->getAllocatedType())) { // If this is a load of the entire alloca to an integer, rewrite it. @@ -588,7 +588,7 @@ new StoreInst(Extract, NewElts[i], SI); } DeadInsts.push_back(SI); - } else if (isa(SIType) && + } else if (SIType->isIntegerTy() && TD->getTypeAllocSize(SIType) == TD->getTypeAllocSize(AI->getAllocatedType())) { // If this is a store of the entire alloca from an integer, rewrite it. @@ -833,7 +833,7 @@ // Convert the integer value to the appropriate type. StoreVal = ConstantInt::get(Context, TotalVal); - if (isa(ValTy)) + if (ValTy->isPointerTy()) StoreVal = ConstantExpr::getIntToPtr(StoreVal, ValTy); else if (ValTy->isFloatingPointTy()) StoreVal = ConstantExpr::getBitCast(StoreVal, ValTy); @@ -939,7 +939,7 @@ Value *DestField = NewElts[i]; if (EltVal->getType() == FieldTy) { // Storing to an integer field of this size, just do it. - } else if (FieldTy->isFloatingPointTy() || isa(FieldTy)) { + } else if (FieldTy->isFloatingPointTy() || FieldTy->isVectorTy()) { // Bitcast to the right element type (for fp/vector values). EltVal = new BitCastInst(EltVal, FieldTy, "", SI); } else { @@ -984,7 +984,7 @@ if (EltVal->getType() == ArrayEltTy) { // Storing to an integer field of this size, just do it. } else if (ArrayEltTy->isFloatingPointTy() || - isa(ArrayEltTy)) { + ArrayEltTy->isVectorTy()) { // Bitcast to the right element type (for fp/vector values). EltVal = new BitCastInst(EltVal, ArrayEltTy, "", SI); } else { @@ -1044,8 +1044,8 @@ const IntegerType *FieldIntTy = IntegerType::get(LI->getContext(), FieldSizeBits); - if (!isa(FieldTy) && !FieldTy->isFloatingPointTy() && - !isa(FieldTy)) + if (!FieldTy->isIntegerTy() && !FieldTy->isFloatingPointTy() && + !FieldTy->isVectorTy()) SrcField = new BitCastInst(SrcField, PointerType::getUnqual(FieldIntTy), "", LI); @@ -1183,7 +1183,7 @@ return; } } else if (In->isFloatTy() || In->isDoubleTy() || - (isa(In) && In->getPrimitiveSizeInBits() >= 8 && + (In->isIntegerTy() && In->getPrimitiveSizeInBits() >= 8 && isPowerOf2_32(In->getPrimitiveSizeInBits()))) { // If we're accessing something that could be an element of a vector, see // if the implied vector agrees with what we already have and if Offset is @@ -1227,7 +1227,7 @@ return false; MergeInType(LI->getType(), Offset, VecTy, AllocaSize, *TD, V->getContext()); - SawVec |= isa(LI->getType()); + SawVec |= LI->getType()->isVectorTy(); continue; } @@ -1236,7 +1236,7 @@ if (SI->getOperand(0) == V || SI->isVolatile()) return 0; MergeInType(SI->getOperand(0)->getType(), Offset, VecTy, AllocaSize, *TD, V->getContext()); - SawVec |= isa(SI->getOperand(0)->getType()); + SawVec |= SI->getOperand(0)->getType()->isVectorTy(); continue; } @@ -1438,7 +1438,7 @@ // If the result alloca is a vector type, this is either an element // access or a bitcast to another vector type of the same size. if (const VectorType *VTy = dyn_cast(FromVal->getType())) { - if (isa(ToType)) + if (ToType->isVectorTy()) return Builder.CreateBitCast(FromVal, ToType, "tmp"); // Otherwise it must be an element access. @@ -1521,9 +1521,9 @@ LIBitWidth), "tmp"); // If the result is an integer, this is a trunc or bitcast. - if (isa(ToType)) { + if (ToType->isIntegerTy()) { // Should be done. - } else if (ToType->isFloatingPointTy() || isa(ToType)) { + } else if (ToType->isFloatingPointTy() || ToType->isVectorTy()) { // Just do a bitcast, we know the sizes match up. FromVal = Builder.CreateBitCast(FromVal, ToType, "tmp"); } else { @@ -1601,10 +1601,10 @@ unsigned DestWidth = TD->getTypeSizeInBits(AllocaType); unsigned SrcStoreWidth = TD->getTypeStoreSizeInBits(SV->getType()); unsigned DestStoreWidth = TD->getTypeStoreSizeInBits(AllocaType); - if (SV->getType()->isFloatingPointTy() || isa(SV->getType())) + if (SV->getType()->isFloatingPointTy() || SV->getType()->isVectorTy()) SV = Builder.CreateBitCast(SV, IntegerType::get(SV->getContext(),SrcWidth), "tmp"); - else if (isa(SV->getType())) + else if (SV->getType()->isPointerTy()) SV = Builder.CreatePtrToInt(SV, TD->getIntPtrType(SV->getContext()), "tmp"); // Zero extend or truncate the value if needed. Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Tue Feb 16 05:11:14 2010 @@ -357,7 +357,7 @@ AWI[0] = AttributeWithIndex::get(2, Attribute::NoCapture); AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind); Constant *F; - if (isa(File->getType())) + if (File->getType()->isPointerTy()) F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI, 2), Type::getInt32Ty(*Context), Type::getInt32Ty(*Context), File->getType(), @@ -384,7 +384,7 @@ AWI[1] = AttributeWithIndex::get(2, Attribute::NoCapture); AWI[2] = AttributeWithIndex::get(~0u, Attribute::NoUnwind); Constant *F; - if (isa(File->getType())) + if (File->getType()->isPointerTy()) F = M->getOrInsertFunction("fputs", AttrListPtr::get(AWI, 3), Type::getInt32Ty(*Context), Type::getInt8PtrTy(*Context), @@ -409,7 +409,7 @@ AWI[1] = AttributeWithIndex::get(4, Attribute::NoCapture); AWI[2] = AttributeWithIndex::get(~0u, Attribute::NoUnwind); Constant *F; - if (isa(File->getType())) + if (File->getType()->isPointerTy()) F = M->getOrInsertFunction("fwrite", AttrListPtr::get(AWI, 3), TD->getIntPtrType(*Context), Type::getInt8PtrTy(*Context), @@ -548,7 +548,7 @@ /// GetStringLength - If we can compute the length of the string pointed to by /// the specified pointer, return 'len+1'. If we can't, return 0. static uint64_t GetStringLength(Value *V) { - if (!isa(V->getType())) return 0; + if (!V->getType()->isPointerTy()) return 0; SmallPtrSet PHIs; uint64_t Len = GetStringLengthH(V, PHIs); @@ -638,7 +638,7 @@ FT->getReturnType() != Type::getInt8PtrTy(*Context) || FT->getParamType(0) != FT->getReturnType() || FT->getParamType(1) != FT->getReturnType() || - !isa(FT->getParamType(2))) + !FT->getParamType(2)->isIntegerTy()) return 0; // Extract some information from the instruction @@ -790,7 +790,7 @@ !FT->getReturnType()->isIntegerTy(32) || FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != Type::getInt8PtrTy(*Context) || - !isa(FT->getParamType(2))) + !FT->getParamType(2)->isIntegerTy()) return 0; Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2); @@ -866,7 +866,7 @@ if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != Type::getInt8PtrTy(*Context) || - !isa(FT->getParamType(2))) + !FT->getParamType(2)->isIntegerTy()) return 0; Value *Dst = CI->getOperand(1); @@ -915,7 +915,7 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 1 || FT->getParamType(0) != Type::getInt8PtrTy(*Context) || - !isa(FT->getReturnType())) + !FT->getReturnType()->isIntegerTy()) return 0; Value *Src = CI->getOperand(1); @@ -939,8 +939,8 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); if ((FT->getNumParams() != 2 && FT->getNumParams() != 3) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1))) + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy()) return 0; Value *EndPtr = CI->getOperand(2); @@ -960,9 +960,9 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 2 || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || - !isa(FT->getReturnType())) + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || + !FT->getReturnType()->isPointerTy()) return 0; // fold strstr(x, x) -> x. @@ -1006,8 +1006,8 @@ struct MemCmpOpt : public LibCallOptimization { virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() != 3 || !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || + if (FT->getNumParams() != 3 || !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || !FT->getReturnType()->isIntegerTy(32)) return 0; @@ -1055,8 +1055,8 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || FT->getParamType(2) != TD->getIntPtrType(*Context)) return 0; @@ -1076,8 +1076,8 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || FT->getParamType(2) != TD->getIntPtrType(*Context)) return 0; @@ -1097,8 +1097,8 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isIntegerTy() || FT->getParamType(2) != TD->getIntPtrType(*Context)) return 0; @@ -1124,9 +1124,9 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 4 || FT->getReturnType() != FT->getParamType(0) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || - !isa(FT->getParamType(3)) || + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || + !FT->getParamType(3)->isIntegerTy() || FT->getParamType(2) != TD->getIntPtrType(*Context)) return 0; @@ -1152,9 +1152,9 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 4 || FT->getReturnType() != FT->getParamType(0) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || - !isa(FT->getParamType(3)) || + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isIntegerTy() || + !FT->getParamType(3)->isIntegerTy() || FT->getParamType(2) != TD->getIntPtrType(*Context)) return 0; @@ -1182,9 +1182,9 @@ const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 4 || FT->getReturnType() != FT->getParamType(0) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || - !isa(FT->getParamType(3)) || + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || + !FT->getParamType(3)->isIntegerTy() || FT->getParamType(2) != TD->getIntPtrType(*Context)) return 0; @@ -1205,8 +1205,8 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || - !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1))) + !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy()) return 0; ConstantInt *SizeCI = dyn_cast(CI->getOperand(3)); @@ -1376,7 +1376,7 @@ // result type. if (FT->getNumParams() != 1 || !FT->getReturnType()->isIntegerTy(32) || - !isa(FT->getParamType(0))) + !FT->getParamType(0)->isIntegerTy()) return 0; Value *Op = CI->getOperand(1); @@ -1410,7 +1410,7 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); // We require integer(i32) - if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || + if (FT->getNumParams() != 1 || !FT->getReturnType()->isIntegerTy() || !FT->getParamType(0)->isIntegerTy(32)) return 0; @@ -1431,7 +1431,7 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); // We require integer(i32) - if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || + if (FT->getNumParams() != 1 || !FT->getReturnType()->isIntegerTy() || !FT->getParamType(0)->isIntegerTy(32)) return 0; @@ -1450,7 +1450,7 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { const FunctionType *FT = Callee->getFunctionType(); // We require integer(integer) where the types agree. - if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || + if (FT->getNumParams() != 1 || !FT->getReturnType()->isIntegerTy() || FT->getParamType(0) != FT->getReturnType()) return 0; @@ -1493,8 +1493,8 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { // Require one fixed pointer argument and an integer/void result. const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() < 1 || !isa(FT->getParamType(0)) || - !(isa(FT->getReturnType()) || + if (FT->getNumParams() < 1 || !FT->getParamType(0)->isPointerTy() || + !(FT->getReturnType()->isIntegerTy() || FT->getReturnType()->isVoidTy())) return 0; @@ -1534,7 +1534,7 @@ // Optimize specific format strings. // printf("%c", chr) --> putchar(*(i8*)dst) if (FormatStr == "%c" && CI->getNumOperands() > 2 && - isa(CI->getOperand(2)->getType())) { + CI->getOperand(2)->getType()->isIntegerTy()) { Value *Res = EmitPutChar(CI->getOperand(2), B); if (CI->use_empty()) return CI; @@ -1543,7 +1543,7 @@ // printf("%s\n", str) --> puts(str) if (FormatStr == "%s\n" && CI->getNumOperands() > 2 && - isa(CI->getOperand(2)->getType()) && + CI->getOperand(2)->getType()->isPointerTy() && CI->use_empty()) { EmitPutS(CI->getOperand(2), B); return CI; @@ -1559,9 +1559,9 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { // Require two fixed pointer arguments and an integer result. const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() != 2 || !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || - !isa(FT->getReturnType())) + if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || + !FT->getReturnType()->isIntegerTy()) return 0; // Check for a fixed format string. @@ -1595,7 +1595,7 @@ // Decode the second character of the format string. if (FormatStr[1] == 'c') { // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 - if (!isa(CI->getOperand(3)->getType())) return 0; + if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; Value *V = B.CreateTrunc(CI->getOperand(3), Type::getInt8Ty(*Context), "char"); Value *Ptr = CastToCStr(CI->getOperand(1), B); @@ -1612,7 +1612,7 @@ if (!TD) return 0; // sprintf(dest, "%s", str) -> llvm.memcpy(dest, str, strlen(str)+1, 1) - if (!isa(CI->getOperand(3)->getType())) return 0; + if (!CI->getOperand(3)->getType()->isPointerTy()) return 0; Value *Len = EmitStrLen(CI->getOperand(3), B); Value *IncLen = B.CreateAdd(Len, @@ -1634,11 +1634,11 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { // Require a pointer, an integer, an integer, a pointer, returning integer. const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() != 4 || !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || - !isa(FT->getParamType(2)) || - !isa(FT->getParamType(3)) || - !isa(FT->getReturnType())) + if (FT->getNumParams() != 4 || !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isIntegerTy() || + !FT->getParamType(2)->isIntegerTy() || + !FT->getParamType(3)->isPointerTy() || + !FT->getReturnType()->isIntegerTy()) return 0; // Get the element size and count. @@ -1672,8 +1672,8 @@ // Require two pointers. Also, we can't optimize if return value is used. const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() != 2 || !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || + if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || !CI->use_empty()) return 0; @@ -1694,9 +1694,9 @@ virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { // Require two fixed paramters as pointers and integer result. const FunctionType *FT = Callee->getFunctionType(); - if (FT->getNumParams() != 2 || !isa(FT->getParamType(0)) || - !isa(FT->getParamType(1)) || - !isa(FT->getReturnType())) + if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() || + !FT->getParamType(1)->isPointerTy() || + !FT->getReturnType()->isIntegerTy()) return 0; // All the optimizations depend on the format string. @@ -1728,14 +1728,14 @@ // Decode the second character of the format string. if (FormatStr[1] == 'c') { // fprintf(F, "%c", chr) --> *(i8*)dst = chr - if (!isa(CI->getOperand(3)->getType())) return 0; + if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; EmitFPutC(CI->getOperand(3), CI->getOperand(1), B); return ConstantInt::get(CI->getType(), 1); } if (FormatStr[1] == 's') { // fprintf(F, "%s", str) -> fputs(str, F) - if (!isa(CI->getOperand(3)->getType()) || !CI->use_empty()) + if (!CI->getOperand(3)->getType()->isPointerTy() || !CI->use_empty()) return 0; EmitFPutS(CI->getOperand(3), CI->getOperand(1), B); return CI; @@ -2000,7 +2000,7 @@ case 's': if (Name == "strlen") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setOnlyReadsMemory(F); setDoesNotThrow(F); @@ -2018,14 +2018,14 @@ Name == "strncpy" || Name == "strtoull") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); } else if (Name == "strxfrm") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2038,8 +2038,8 @@ Name == "strcasecmp" || Name == "strncasecmp") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setOnlyReadsMemory(F); setDoesNotThrow(F); @@ -2048,7 +2048,7 @@ } else if (Name == "strstr" || Name == "strpbrk") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setOnlyReadsMemory(F); setDoesNotThrow(F); @@ -2056,7 +2056,7 @@ } else if (Name == "strtok" || Name == "strtok_r") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); @@ -2064,15 +2064,15 @@ Name == "setbuf" || Name == "setvbuf") { if (FTy->getNumParams() < 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "strdup" || Name == "strndup") { if (FTy->getNumParams() < 1 || - !isa(FTy->getReturnType()) || - !isa(FTy->getParamType(0))) + !FTy->getReturnType()->isPointerTy() || + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); @@ -2082,31 +2082,31 @@ Name == "sprintf" || Name == "statvfs") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); } else if (Name == "snprintf") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(2))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(2)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 3); } else if (Name == "setitimer") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(1)) || - !isa(FTy->getParamType(2))) + !FTy->getParamType(1)->isPointerTy() || + !FTy->getParamType(2)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); setDoesNotCapture(F, 3); } else if (Name == "system") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; // May throw; "system" is a valid pthread cancellation point. setDoesNotCapture(F, 1); @@ -2115,14 +2115,14 @@ case 'm': if (Name == "malloc") { if (FTy->getNumParams() != 1 || - !isa(FTy->getReturnType())) + !FTy->getReturnType()->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); } else if (Name == "memcmp") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setOnlyReadsMemory(F); setDoesNotThrow(F); @@ -2141,18 +2141,18 @@ Name == "memccpy" || Name == "memmove") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); } else if (Name == "memalign") { - if (!isa(FTy->getReturnType())) + if (!FTy->getReturnType()->isPointerTy()) continue; setDoesNotAlias(F, 0); } else if (Name == "mkdir" || Name == "mktime") { if (FTy->getNumParams() == 0 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2161,15 +2161,15 @@ case 'r': if (Name == "realloc") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getReturnType())) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getReturnType()->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); setDoesNotCapture(F, 1); } else if (Name == "read") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; // May throw; "read" is a valid pthread cancellation point. setDoesNotCapture(F, 2); @@ -2178,15 +2178,15 @@ Name == "remove" || Name == "realpath") { if (FTy->getNumParams() < 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "rename" || Name == "readlink") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2196,7 +2196,7 @@ case 'w': if (Name == "write") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; // May throw; "write" is a valid pthread cancellation point. setDoesNotCapture(F, 2); @@ -2205,16 +2205,16 @@ case 'b': if (Name == "bcopy") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); } else if (Name == "bcmp") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setOnlyReadsMemory(F); @@ -2222,7 +2222,7 @@ setDoesNotCapture(F, 2); } else if (Name == "bzero") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2231,7 +2231,7 @@ case 'c': if (Name == "calloc") { if (FTy->getNumParams() != 2 || - !isa(FTy->getReturnType())) + !FTy->getReturnType()->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); @@ -2241,7 +2241,7 @@ Name == "clearerr" || Name == "closedir") { if (FTy->getNumParams() == 0 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2253,14 +2253,14 @@ Name == "atof" || Name == "atoll") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setOnlyReadsMemory(F); setDoesNotCapture(F, 1); } else if (Name == "access") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2269,9 +2269,9 @@ case 'f': if (Name == "fopen") { if (FTy->getNumParams() != 2 || - !isa(FTy->getReturnType()) || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getReturnType()->isPointerTy() || + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); @@ -2279,8 +2279,8 @@ setDoesNotCapture(F, 2); } else if (Name == "fdopen") { if (FTy->getNumParams() != 2 || - !isa(FTy->getReturnType()) || - !isa(FTy->getParamType(1))) + !FTy->getReturnType()->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); @@ -2300,13 +2300,13 @@ Name == "funlockfile" || Name == "ftrylockfile") { if (FTy->getNumParams() == 0 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "ferror") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2318,22 +2318,22 @@ Name == "frexpl" || Name == "fstatvfs") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); } else if (Name == "fgets") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(2))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(2)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 3); } else if (Name == "fread" || Name == "fwrite") { if (FTy->getNumParams() != 4 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(3))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(3)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2343,8 +2343,8 @@ Name == "fprintf" || Name == "fgetpos") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2356,13 +2356,13 @@ Name == "getlogin_r" || Name == "getc_unlocked") { if (FTy->getNumParams() == 0 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "getenv") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setOnlyReadsMemory(F); @@ -2372,13 +2372,13 @@ setDoesNotThrow(F); } else if (Name == "getitimer") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); } else if (Name == "getpwnam") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2387,7 +2387,7 @@ case 'u': if (Name == "ungetc") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); @@ -2395,15 +2395,15 @@ Name == "unlink" || Name == "unsetenv") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "utime" || Name == "utimes") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2413,7 +2413,7 @@ case 'p': if (Name == "putc") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); @@ -2421,14 +2421,14 @@ Name == "printf" || Name == "perror") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "pread" || Name == "pwrite") { if (FTy->getNumParams() != 4 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; // May throw; these are valid pthread cancellation points. setDoesNotCapture(F, 2); @@ -2436,9 +2436,9 @@ setDoesNotThrow(F); } else if (Name == "popen") { if (FTy->getNumParams() != 2 || - !isa(FTy->getReturnType()) || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getReturnType()->isPointerTy() || + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); @@ -2446,7 +2446,7 @@ setDoesNotCapture(F, 2); } else if (Name == "pclose") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2455,43 +2455,43 @@ case 'v': if (Name == "vscanf") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "vsscanf" || Name == "vfscanf") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(1)) || - !isa(FTy->getParamType(2))) + !FTy->getParamType(1)->isPointerTy() || + !FTy->getParamType(2)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); } else if (Name == "valloc") { - if (!isa(FTy->getReturnType())) + if (!FTy->getReturnType()->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); } else if (Name == "vprintf") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "vfprintf" || Name == "vsprintf") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); } else if (Name == "vsnprintf") { if (FTy->getNumParams() != 4 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(2))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(2)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2501,14 +2501,14 @@ case 'o': if (Name == "open") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; // May throw; "open" is a valid pthread cancellation point. setDoesNotCapture(F, 1); } else if (Name == "opendir") { if (FTy->getNumParams() != 1 || - !isa(FTy->getReturnType()) || - !isa(FTy->getParamType(0))) + !FTy->getReturnType()->isPointerTy() || + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); @@ -2517,13 +2517,13 @@ break; case 't': if (Name == "tmpfile") { - if (!isa(FTy->getReturnType())) + if (!FTy->getReturnType()->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); } else if (Name == "times") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2546,15 +2546,15 @@ case 'l': if (Name == "lstat") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); } else if (Name == "lchown") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2563,7 +2563,7 @@ case 'q': if (Name == "qsort") { if (FTy->getNumParams() != 4 || - !isa(FTy->getParamType(3))) + !FTy->getParamType(3)->isPointerTy()) continue; // May throw; places call through function pointer. setDoesNotCapture(F, 4); @@ -2573,27 +2573,27 @@ if (Name == "__strdup" || Name == "__strndup") { if (FTy->getNumParams() < 1 || - !isa(FTy->getReturnType()) || - !isa(FTy->getParamType(0))) + !FTy->getReturnType()->isPointerTy() || + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); setDoesNotCapture(F, 1); } else if (Name == "__strtok_r") { if (FTy->getNumParams() != 3 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); } else if (Name == "_IO_getc") { if (FTy->getNumParams() != 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "_IO_putc") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); @@ -2602,7 +2602,7 @@ case 1: if (Name == "\1__isoc99_scanf") { if (FTy->getNumParams() < 1 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); @@ -2611,17 +2611,17 @@ Name == "\1statvfs64" || Name == "\1__isoc99_sscanf") { if (FTy->getNumParams() < 1 || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); setDoesNotCapture(F, 2); } else if (Name == "\1fopen64") { if (FTy->getNumParams() != 2 || - !isa(FTy->getReturnType()) || - !isa(FTy->getParamType(0)) || - !isa(FTy->getParamType(1))) + !FTy->getReturnType()->isPointerTy() || + !FTy->getParamType(0)->isPointerTy() || + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); @@ -2630,25 +2630,25 @@ } else if (Name == "\1fseeko64" || Name == "\1ftello64") { if (FTy->getNumParams() == 0 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 1); } else if (Name == "\1tmpfile64") { - if (!isa(FTy->getReturnType())) + if (!FTy->getReturnType()->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotAlias(F, 0); } else if (Name == "\1fstat64" || Name == "\1fstatvfs64") { if (FTy->getNumParams() != 2 || - !isa(FTy->getParamType(1))) + !FTy->getParamType(1)->isPointerTy()) continue; setDoesNotThrow(F); setDoesNotCapture(F, 2); } else if (Name == "\1open64") { if (FTy->getNumParams() < 2 || - !isa(FTy->getParamType(0))) + !FTy->getParamType(0)->isPointerTy()) continue; // May throw; "open" is a valid pthread cancellation point. setDoesNotCapture(F, 1); Modified: llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/AddrModeMatcher.cpp Tue Feb 16 05:11:14 2010 @@ -125,7 +125,7 @@ // Don't touch identity bitcasts. if (I->getType() == I->getOperand(0)->getType()) return false; - return isa(I->getType()) || isa(I->getType()); + return I->getType()->isPointerTy() || I->getType()->isIntegerTy(); case Instruction::PtrToInt: // PtrToInt is always a noop, as we know that the int type is pointer sized. return true; @@ -167,8 +167,8 @@ case Instruction::BitCast: // BitCast is always a noop, and we can handle it as long as it is // int->int or pointer->pointer (we don't want int<->fp or something). - if ((isa(AddrInst->getOperand(0)->getType()) || - isa(AddrInst->getOperand(0)->getType())) && + if ((AddrInst->getOperand(0)->getType()->isPointerTy() || + AddrInst->getOperand(0)->getType()->isIntegerTy()) && // Don't touch identity bitcasts. These were probably put here by LSR, // and we don't want to mess around with them. Assume it knows what it // is doing. @@ -569,7 +569,7 @@ // Get the access type of this use. If the use isn't a pointer, we don't // know what it accesses. Value *Address = User->getOperand(OpNo); - if (!isa(Address->getType())) + if (!Address->getType()->isPointerTy()) return false; const Type *AddressAccessTy = cast(Address->getType())->getElementType(); Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Feb 16 05:11:14 2010 @@ -46,7 +46,7 @@ static Value *getUnderlyingObjectWithOffset(Value *V, const TargetData *TD, uint64_t &ByteOffset, unsigned MaxLookup = 6) { - if (!isa(V->getType())) + if (!V->getType()->isPointerTy()) return V; for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) { if (GEPOperator *GEP = dyn_cast(V)) { @@ -65,7 +65,7 @@ } else { return V; } - assert(isa(V->getType()) && "Unexpected operand type!"); + assert(V->getType()->isPointerTy() && "Unexpected operand type!"); } return V; } Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Tue Feb 16 05:11:14 2010 @@ -518,7 +518,7 @@ // If this PHI node merges one value and/or undefs, get the value. if (Value *V = PN->hasConstantValue(&DT)) { - if (AST && isa(PN->getType())) + if (AST && PN->getType()->isPointerTy()) AST->deleteValue(PN); PN->replaceAllUsesWith(V); PN->eraseFromParent(); @@ -780,7 +780,7 @@ if (ReplVal == LI) ReplVal = UndefValue::get(LI->getType()); LI->replaceAllUsesWith(ReplVal); - if (AST && isa(LI->getType())) + if (AST && LI->getType()->isPointerTy()) AST->deleteValue(LI); LI->eraseFromParent(); LBI.deleteValue(LI); @@ -838,7 +838,7 @@ for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); UI != E;) if (LoadInst *LI = dyn_cast(*UI++)) { LI->replaceAllUsesWith(UndefValue::get(LI->getType())); - if (AST && isa(LI->getType())) + if (AST && LI->getType()->isPointerTy()) AST->deleteValue(LI); LBI.deleteValue(LI); LI->eraseFromParent(); @@ -874,7 +874,7 @@ // Otherwise, there was a store before this load, the load takes its value. --I; LI->replaceAllUsesWith(I->second->getOperand(0)); - if (AST && isa(LI->getType())) + if (AST && LI->getType()->isPointerTy()) AST->deleteValue(LI); LI->eraseFromParent(); LBI.deleteValue(LI); @@ -922,7 +922,7 @@ InsertedPHINodes.insert(PN); - if (AST && isa(PN->getType())) + if (AST && PN->getType()->isPointerTy()) AST->copyValue(PointerAllocaValues[AllocaNo], PN); return true; @@ -996,7 +996,7 @@ // Anything using the load now uses the current value. LI->replaceAllUsesWith(V); - if (AST && isa(LI->getType())) + if (AST && LI->getType()->isPointerTy()) AST->deleteValue(LI); BB->getInstList().erase(LI); } else if (StoreInst *SI = dyn_cast(I)) { Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Feb 16 05:11:14 2010 @@ -271,7 +271,7 @@ ConstantInt *SimplifyCFGOpt::GetConstantInt(Value *V) { // Normal constant int. ConstantInt *CI = dyn_cast(V); - if (CI || !TD || !isa(V) || !isa(V->getType())) + if (CI || !TD || !isa(V) || !V->getType()->isPointerTy()) return CI; // This is some kind of pointer constant. Turn it into a pointer-sized @@ -701,7 +701,7 @@ AddPredecessorToBlock(NewSuccessors[i], Pred, BB); // Convert pointer to int before we switch. - if (isa(CV->getType())) { + if (CV->getType()->isPointerTy()) { assert(TD && "Cannot switch on pointer without TargetData"); CV = new PtrToIntInst(CV, TD->getIntPtrType(CV->getContext()), "magicptr", PTI); @@ -915,7 +915,7 @@ case Instruction::Add: case Instruction::Sub: // Not worth doing for vector ops. - if (isa(HInst->getType())) + if (HInst->getType()->isVectorTy()) return false; break; case Instruction::And: @@ -925,7 +925,7 @@ case Instruction::LShr: case Instruction::AShr: // Don't mess with vector operations. - if (isa(HInst->getType())) + if (HInst->getType()->isVectorTy()) return false; break; // These are all cheap and non-trapping instructions. } @@ -2068,7 +2068,7 @@ if (!TrueWhenEqual) std::swap(DefaultBB, EdgeBB); // Convert pointer to int before we switch. - if (isa(CompVal->getType())) { + if (CompVal->getType()->isPointerTy()) { assert(TD && "Cannot switch on pointer without TargetData"); CompVal = new PtrToIntInst(CompVal, TD->getIntPtrType(CompVal->getContext()), Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Feb 16 05:11:14 2010 @@ -376,7 +376,7 @@ return; // If this is a structure or opaque type, add a name for the type. - if (((isa(Ty) && cast(Ty)->getNumElements()) + if (((Ty->isStructTy() && cast(Ty)->getNumElements()) || isa(Ty)) && !TP.hasTypeName(Ty)) { TP.addTypeName(Ty, "%"+utostr(unsigned(NumberedTypes.size()))); NumberedTypes.push_back(Ty); @@ -1850,8 +1850,8 @@ // Out << ' '; if (!FTy->isVarArg() && - (!isa(RetTy) || - !isa(cast(RetTy)->getElementType()))) { + (!RetTy->isPointerTy() || + !cast(RetTy)->getElementType()->isFunctionTy())) { TypePrinter.print(RetTy, Out); Out << ' '; writeOperand(Operand, false); @@ -1896,8 +1896,8 @@ // Out << ' '; if (!FTy->isVarArg() && - (!isa(RetTy) || - !isa(cast(RetTy)->getElementType()))) { + (!RetTy->isPointerTy() || + !cast(RetTy)->getElementType()->isFunctionTy())) { TypePrinter.print(RetTy, Out); Out << ' '; writeOperand(Operand, false); Modified: llvm/trunk/lib/VMCore/Attributes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Attributes.cpp (original) +++ llvm/trunk/lib/VMCore/Attributes.cpp Tue Feb 16 05:11:14 2010 @@ -93,7 +93,7 @@ // Attributes that only apply to integers. Incompatible |= SExt | ZExt; - if (!isa(Ty)) + if (!Ty->isPointerTy()) // Attributes that only apply to pointers. Incompatible |= ByVal | Nest | NoAlias | StructRet | NoCapture; Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Feb 16 05:11:14 2010 @@ -112,7 +112,7 @@ IdxList.push_back(Zero); } else if (const SequentialType *STy = dyn_cast(ElTy)) { - if (isa(ElTy)) break; // Can't index into pointers! + if (ElTy->isPointerTy()) break; // Can't index into pointers! ElTy = STy->getElementType(); IdxList.push_back(Zero); } else { @@ -189,7 +189,7 @@ /// static Constant *ExtractConstantBytes(Constant *C, unsigned ByteStart, unsigned ByteSize) { - assert(isa(C->getType()) && + assert(C->getType()->isIntegerTy() && (cast(C->getType())->getBitWidth() & 7) == 0 && "Non-byte sized integer input"); unsigned CSize = cast(C->getType())->getBitWidth()/8; @@ -551,7 +551,7 @@ // operating on each element. In the cast of bitcasts, the element // count may be mismatched; don't attempt to handle that here. if (ConstantVector *CV = dyn_cast(V)) - if (isa(DestTy) && + if (DestTy->isVectorTy() && cast(DestTy)->getNumElements() == CV->getType()->getNumElements()) { std::vector res; @@ -634,7 +634,7 @@ } } // Handle an offsetof-like expression. - if (isa(Ty) || isa(Ty) || isa(Ty)){ + if (Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()){ if (Constant *C = getFoldedOffsetOf(Ty, CE->getOperand(2), DestTy, false)) return C; @@ -885,7 +885,7 @@ unsigned numOps; if (const ArrayType *AR = dyn_cast(AggTy)) numOps = AR->getNumElements(); - else if (isa(AggTy)) + else if (AggTy->isUnionTy()) numOps = 1; else numOps = cast(AggTy)->getNumElements(); @@ -1667,7 +1667,7 @@ // If the cast is not actually changing bits, and the second operand is a // null pointer, do the comparison with the pre-casted value. if (V2->isNullValue() && - (isa(CE1->getType()) || CE1->getType()->isIntegerTy())) { + (CE1->getType()->isPointerTy() || CE1->getType()->isIntegerTy())) { if (CE1->getOpcode() == Instruction::ZExt) isSigned = false; if (CE1->getOpcode() == Instruction::SExt) isSigned = true; return evaluateICmpRelation(CE1Op0, @@ -1914,7 +1914,7 @@ return ConstantInt::get(ResultTy, R==APFloat::cmpGreaterThan || R==APFloat::cmpEqual); } - } else if (isa(C1->getType())) { + } else if (C1->getType()->isVectorTy()) { SmallVector C1Elts, C2Elts; C1->getVectorElements(C1Elts); C2->getVectorElements(C2Elts); @@ -2065,7 +2065,7 @@ if (ConstantExpr *CE2 = dyn_cast(C2)) { Constant *CE2Op0 = CE2->getOperand(0); if (CE2->getOpcode() == Instruction::BitCast && - isa(CE2->getType())==isa(CE2Op0->getType())) { + CE2->getType()->isVectorTy()==CE2Op0->getType()->isVectorTy()) { Constant *Inverse = ConstantExpr::getBitCast(C1, CE2Op0->getType()); return ConstantExpr::getICmp(pred, Inverse, CE2Op0); } @@ -2184,7 +2184,7 @@ I != E; ++I) LastTy = *I; - if ((LastTy && isa(LastTy)) || Idx0->isNullValue()) { + if ((LastTy && LastTy->isArrayTy()) || Idx0->isNullValue()) { SmallVector NewIndices; NewIndices.reserve(NumIdx + CE->getNumOperands()); for (unsigned i = 1, e = CE->getNumOperands()-1; i != e; ++i) Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Feb 16 05:11:14 2010 @@ -229,7 +229,7 @@ /// This handles breaking down a vector undef into undef elements, etc. For /// constant exprs and other cases we can't handle, we return an empty vector. void Constant::getVectorElements(SmallVectorImpl &Elts) const { - assert(isa(getType()) && "Not a vector constant!"); + assert(getType()->isVectorTy() && "Not a vector constant!"); if (const ConstantVector *CV = dyn_cast(this)) { for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) @@ -944,7 +944,7 @@ // Factory Function Implementation ConstantAggregateZero* ConstantAggregateZero::get(const Type* Ty) { - assert((isa(Ty) || isa(Ty) || isa(Ty)) && + assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) && "Cannot create an aggregate zero of non-aggregate type!"); LLVMContextImpl *pImpl = Ty->getContext().pImpl; @@ -1239,8 +1239,8 @@ } Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) { - assert(isa(S->getType()) && "Invalid cast"); - assert((Ty->isIntegerTy() || isa(Ty)) && "Invalid cast"); + assert(S->getType()->isPointerTy() && "Invalid cast"); + assert((Ty->isIntegerTy() || Ty->isPointerTy()) && "Invalid cast"); if (Ty->isIntegerTy()) return getCast(Instruction::PtrToInt, S, Ty); @@ -1383,14 +1383,14 @@ } Constant *ConstantExpr::getPtrToInt(Constant *C, const Type *DstTy) { - assert(isa(C->getType()) && "PtrToInt source must be pointer"); + assert(C->getType()->isPointerTy() && "PtrToInt source must be pointer"); assert(DstTy->isIntegerTy() && "PtrToInt destination must be integral"); return getFoldedCast(Instruction::PtrToInt, C, DstTy); } Constant *ConstantExpr::getIntToPtr(Constant *C, const Type *DstTy) { assert(C->getType()->isIntegerTy() && "IntToPtr source must be integral"); - assert(isa(DstTy) && "IntToPtr destination must be a pointer"); + assert(DstTy->isPointerTy() && "IntToPtr destination must be a pointer"); return getFoldedCast(Instruction::IntToPtr, C, DstTy); } @@ -1592,7 +1592,7 @@ (Constant**)Idxs, NumIdx)) return FC; // Fold a few common cases... - assert(isa(C->getType()) && + assert(C->getType()->isPointerTy() && "Non-pointer type for constant GetElementPtr expression"); // Look up the constant in the table first to ensure uniqueness std::vector ArgVec; @@ -1619,7 +1619,7 @@ (Constant**)Idxs, NumIdx)) return FC; // Fold a few common cases... - assert(isa(C->getType()) && + assert(C->getType()->isPointerTy() && "Non-pointer type for constant GetElementPtr expression"); // Look up the constant in the table first to ensure uniqueness std::vector ArgVec; @@ -1727,7 +1727,7 @@ } Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) { - assert(isa(Val->getType()) && + assert(Val->getType()->isVectorTy() && "Tried to create extractelement operation on non-vector type!"); assert(Idx->getType()->isIntegerTy(32) && "Extractelement index must be i32 type!"); @@ -1751,7 +1751,7 @@ Constant *ConstantExpr::getInsertElement(Constant *Val, Constant *Elt, Constant *Idx) { - assert(isa(Val->getType()) && + assert(Val->getType()->isVectorTy() && "Tried to create insertelement operation on non-vector type!"); assert(Elt->getType() == cast(Val->getType())->getElementType() && "Insertelement types must match!"); Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Tue Feb 16 05:11:14 2010 @@ -73,35 +73,35 @@ /// hasByValAttr - Return true if this argument has the byval attribute on it /// in its containing function. bool Argument::hasByValAttr() const { - if (!isa(getType())) return false; + if (!getType()->isPointerTy()) return false; return getParent()->paramHasAttr(getArgNo()+1, Attribute::ByVal); } /// hasNestAttr - Return true if this argument has the nest attribute on /// it in its containing function. bool Argument::hasNestAttr() const { - if (!isa(getType())) return false; + if (!getType()->isPointerTy()) return false; return getParent()->paramHasAttr(getArgNo()+1, Attribute::Nest); } /// hasNoAliasAttr - Return true if this argument has the noalias attribute on /// it in its containing function. bool Argument::hasNoAliasAttr() const { - if (!isa(getType())) return false; + if (!getType()->isPointerTy()) return false; return getParent()->paramHasAttr(getArgNo()+1, Attribute::NoAlias); } /// hasNoCaptureAttr - Return true if this argument has the nocapture attribute /// on it in its containing function. bool Argument::hasNoCaptureAttr() const { - if (!isa(getType())) return false; + if (!getType()->isPointerTy()) return false; return getParent()->paramHasAttr(getArgNo()+1, Attribute::NoCapture); } /// hasSRetAttr - Return true if this argument has the sret attribute on /// it in its containing function. bool Argument::hasStructRetAttr() const { - if (!isa(getType())) return false; + if (!getType()->isPointerTy()) return false; if (this != getParent()->arg_begin()) return false; // StructRet param must be first param return getParent()->paramHasAttr(1, Attribute::StructRet); Modified: llvm/trunk/lib/VMCore/InlineAsm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/InlineAsm.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/InlineAsm.cpp (original) +++ llvm/trunk/lib/VMCore/InlineAsm.cpp Tue Feb 16 05:11:14 2010 @@ -220,7 +220,7 @@ if (!Ty->getReturnType()->isVoidTy()) return false; break; case 1: - if (isa(Ty->getReturnType())) return false; + if (Ty->getReturnType()->isStructTy()) return false; break; default: const StructType *STy = dyn_cast(Ty->getReturnType()); Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Feb 16 05:11:14 2010 @@ -562,7 +562,7 @@ BasicBlock *InsertAtEnd) { assert(((!InsertBefore && InsertAtEnd) || (InsertBefore && !InsertAtEnd)) && "createFree needs either InsertBefore or InsertAtEnd"); - assert(isa(Source->getType()) && + assert(Source->getType()->isPointerTy() && "Can not free something of nonpointer type!"); BasicBlock* BB = InsertBefore ? InsertBefore->getParent() : InsertAtEnd; @@ -989,7 +989,7 @@ //===----------------------------------------------------------------------===// void LoadInst::AssertOK() { - assert(isa(getOperand(0)->getType()) && + assert(getOperand(0)->getType()->isPointerTy() && "Ptr must have pointer type."); } @@ -1103,7 +1103,7 @@ void StoreInst::AssertOK() { assert(getOperand(0) && getOperand(1) && "Both operands must be non-null!"); - assert(isa(getOperand(1)->getType()) && + assert(getOperand(1)->getType()->isPointerTy() && "Ptr must have pointer type!"); assert(getOperand(0)->getType() == cast(getOperand(1)->getType())->getElementType() @@ -1285,7 +1285,7 @@ unsigned CurIdx = 1; for (; CurIdx != NumIdx; ++CurIdx) { const CompositeType *CT = dyn_cast(Agg); - if (!CT || isa(CT)) return 0; + if (!CT || CT->isPointerTy()) return 0; IndexTy Index = Idxs[CurIdx]; if (!CT->indexValid(Index)) return 0; Agg = CT->getTypeAtIndex(Index); @@ -1391,7 +1391,7 @@ bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) { - if (!isa(Val->getType()) || !Index->getType()->isIntegerTy(32)) + if (!Val->getType()->isVectorTy() || !Index->getType()->isIntegerTy(32)) return false; return true; } @@ -1432,7 +1432,7 @@ bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt, const Value *Index) { - if (!isa(Vec->getType())) + if (!Vec->getType()->isVectorTy()) return false; // First operand of insertelement must be vector type. if (Elt->getType() != cast(Vec->getType())->getElementType()) @@ -1485,7 +1485,7 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2, const Value *Mask) { - if (!isa(V1->getType()) || V1->getType() != V2->getType()) + if (!V1->getType()->isVectorTy() || V1->getType() != V2->getType()) return false; const VectorType *MaskTy = dyn_cast(Mask->getType()); @@ -1602,7 +1602,7 @@ unsigned CurIdx = 0; for (; CurIdx != NumIdx; ++CurIdx) { const CompositeType *CT = dyn_cast(Agg); - if (!CT || isa(CT) || isa(CT)) return 0; + if (!CT || CT->isPointerTy() || CT->isVectorTy()) return 0; unsigned Index = Idxs[CurIdx]; if (!CT->indexValid(Index)) return 0; Agg = CT->getTypeAtIndex(Index); @@ -1693,7 +1693,7 @@ case SDiv: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert((getType()->isIntegerTy() || (isa(getType()) && + assert((getType()->isIntegerTy() || (getType()->isVectorTy() && cast(getType())->getElementType()->isIntegerTy())) && "Incorrect operand type (not integer) for S/UDIV"); break; @@ -1707,7 +1707,7 @@ case SRem: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert((getType()->isIntegerTy() || (isa(getType()) && + assert((getType()->isIntegerTy() || (getType()->isVectorTy() && cast(getType())->getElementType()->isIntegerTy())) && "Incorrect operand type (not integer) for S/UREM"); break; @@ -1723,7 +1723,7 @@ assert(getType() == LHS->getType() && "Shift operation should return same type as operands!"); assert((getType()->isIntegerTy() || - (isa(getType()) && + (getType()->isVectorTy() && cast(getType())->getElementType()->isIntegerTy())) && "Tried to create a shift operation on a non-integral type!"); break; @@ -1732,7 +1732,7 @@ assert(getType() == LHS->getType() && "Logical operation should return same type as operands!"); assert((getType()->isIntegerTy() || - (isa(getType()) && + (getType()->isVectorTy() && cast(getType())->getElementType()->isIntegerTy())) && "Tried to create a logical operation on a non-integral type!"); break; @@ -1977,8 +1977,8 @@ return true; // Pointer to pointer is always lossless. - if (isa(SrcTy)) - return isa(DstTy); + if (SrcTy->isPointerTy()) + return DstTy->isPointerTy(); return false; // Other types have no identity values } @@ -2094,7 +2094,7 @@ // no-op cast in second op implies firstOp as long as the DestTy // is integer and we are not converting between a vector and a // non vector type. - if (!isa(SrcTy) && DstTy->isIntegerTy()) + if (!SrcTy->isVectorTy() && DstTy->isIntegerTy()) return firstOp; return 0; case 4: @@ -2148,12 +2148,12 @@ case 11: // bitcast followed by ptrtoint is allowed as long as the bitcast // is a pointer to pointer cast. - if (isa(SrcTy) && isa(MidTy)) + if (SrcTy->isPointerTy() && MidTy->isPointerTy()) return secondOp; return 0; case 12: // inttoptr, bitcast -> intptr if bitcast is a ptr to ptr cast - if (isa(MidTy) && isa(DstTy)) + if (MidTy->isPointerTy() && DstTy->isPointerTy()) return firstOp; return 0; case 13: { @@ -2274,8 +2274,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd) { - assert(isa(S->getType()) && "Invalid cast"); - assert((Ty->isIntegerTy() || isa(Ty)) && + assert(S->getType()->isPointerTy() && "Invalid cast"); + assert((Ty->isIntegerTy() || Ty->isPointerTy()) && "Invalid cast"); if (Ty->isIntegerTy()) @@ -2287,8 +2287,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty, const Twine &Name, Instruction *InsertBefore) { - assert(isa(S->getType()) && "Invalid cast"); - assert((Ty->isIntegerTy() || isa(Ty)) && + assert(S->getType()->isPointerTy() && "Invalid cast"); + assert((Ty->isIntegerTy() || Ty->isPointerTy()) && "Invalid cast"); if (Ty->isIntegerTy()) @@ -2373,7 +2373,7 @@ // Casting from vector return DestBits == PTy->getBitWidth(); } else { // Casting from something else - return isa(SrcTy); + return SrcTy->isPointerTy(); } } else if (DestTy->isFloatingPointTy()) { // Casting to floating pt if (SrcTy->isIntegerTy()) { // Casting from integral @@ -2394,8 +2394,8 @@ } else { // Casting from something else return DestPTy->getBitWidth() == SrcBits; } - } else if (isa(DestTy)) { // Casting to pointer - if (isa(SrcTy)) { // Casting from pointer + } else if (DestTy->isPointerTy()) { // Casting to pointer + if (SrcTy->isPointerTy()) { // Casting from pointer return true; } else if (SrcTy->isIntegerTy()) { // Casting from integral return true; @@ -2449,7 +2449,7 @@ PTy = NULL; return BitCast; // Same size, no-op cast } else { - assert(isa(SrcTy) && + assert(SrcTy->isPointerTy() && "Casting from a value that is not first-class type"); return PtrToInt; // ptr -> int } @@ -2486,8 +2486,8 @@ } else { assert(!"Illegal cast to vector (wrong type or size)"); } - } else if (isa(DestTy)) { - if (isa(SrcTy)) { + } else if (DestTy->isPointerTy()) { + if (SrcTy->isPointerTy()) { return BitCast; // ptr -> ptr } else if (SrcTy->isIntegerTy()) { return IntToPtr; // int -> ptr @@ -2566,13 +2566,13 @@ } return SrcTy->isFPOrFPVectorTy() && DstTy->isIntOrIntVectorTy(); case Instruction::PtrToInt: - return isa(SrcTy) && DstTy->isIntegerTy(); + return SrcTy->isPointerTy() && DstTy->isIntegerTy(); case Instruction::IntToPtr: - return SrcTy->isIntegerTy() && isa(DstTy); + return SrcTy->isIntegerTy() && DstTy->isPointerTy(); case Instruction::BitCast: // BitCast implies a no-op cast of type only. No bits change. // However, you can't cast pointers to anything but pointers. - if (isa(SrcTy) != isa(DstTy)) + if (SrcTy->isPointerTy() != DstTy->isPointerTy()) return false; // Now we know we're not dealing with a pointer/non-pointer mismatch. In all @@ -3150,7 +3150,7 @@ //===----------------------------------------------------------------------===// void IndirectBrInst::init(Value *Address, unsigned NumDests) { - assert(Address && isa(Address->getType()) && + assert(Address && Address->getType()->isPointerTy() && "Address of indirectbr must be a pointer"); ReservedSpace = 1+NumDests; NumOperands = 1; Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Feb 16 05:11:14 2010 @@ -61,8 +61,8 @@ // Structures and Functions allocate their contained types past the end of // the type object itself. These need to be destroyed differently than the // other types. - if (isa(this) || isa(this) || - isa(this)) { + if (this->isFunctionTy() || this->isStructTy() || + this->isUnionTy()) { // First, make sure we destruct any PATypeHandles allocated by these // subclasses. They must be manually destructed. for (unsigned i = 0; i < NumContainedTys; ++i) @@ -70,9 +70,9 @@ // Now call the destructor for the subclass directly because we're going // to delete this as an array of char. - if (isa(this)) + if (this->isFunctionTy()) static_cast(this)->FunctionType::~FunctionType(); - else if (isa(this)) + else if (this->isStructTy()) static_cast(this)->StructType::~StructType(); else static_cast(this)->UnionType::~UnionType(); @@ -176,8 +176,8 @@ // At this point we have only various mismatches of the first class types // remaining and ptr->ptr. Just select the lossless conversions. Everything // else is not lossless. - if (isa(this)) - return isa(Ty); + if (this->isPointerTy()) + return Ty->isPointerTy(); return false; // Other types have no identity values } @@ -220,7 +220,7 @@ /// iff all of the members of the type are sized as well. Since asking for /// their size is relatively uncommon, move this operation out of line. bool Type::isSizedDerivedType() const { - if (isa(this)) + if (this->isIntegerTy()) return true; if (const ArrayType *ATy = dyn_cast(this)) @@ -229,7 +229,7 @@ if (const VectorType *PTy = dyn_cast(this)) return PTy->getElementType()->isSized(); - if (!isa(this) && !isa(this)) + if (!this->isStructTy() && !this->isUnionTy()) return false; // Okay, our struct is sized if all of the elements are... @@ -888,7 +888,7 @@ bool ArrayType::isValidElementType(const Type *ElemTy) { return ElemTy->getTypeID() != VoidTyID && ElemTy->getTypeID() != LabelTyID && - ElemTy->getTypeID() != MetadataTyID && !isa(ElemTy); + ElemTy->getTypeID() != MetadataTyID && !ElemTy->isFunctionTy(); } VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) { @@ -955,7 +955,7 @@ bool StructType::isValidElementType(const Type *ElemTy) { return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() && - !ElemTy->isMetadataTy() && !isa(ElemTy); + !ElemTy->isMetadataTy() && !ElemTy->isFunctionTy(); } @@ -1303,7 +1303,7 @@ } bool SequentialType::indexValid(const Value *V) const { - if (isa(V->getType())) + if (V->getType()->isIntegerTy()) return true; return false; } Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Tue Feb 16 05:11:14 2010 @@ -45,7 +45,7 @@ UseList(0), Name(0) { if (isa(this) || isa(this)) assert((VTy->isFirstClassType() || VTy->isVoidTy() || - isa(ty) || VTy->getTypeID() == Type::StructTyID) && + isa(ty) || VTy->isStructTy()) && "invalid CallInst type!"); else if (!isa(this) && !isa(this)) assert((VTy->isFirstClassType() || VTy->isVoidTy() || @@ -320,7 +320,7 @@ } Value *Value::stripPointerCasts() { - if (!isa(getType())) + if (!getType()->isPointerTy()) return this; Value *V = this; do { @@ -337,12 +337,12 @@ } else { return V; } - assert(isa(V->getType()) && "Unexpected operand type!"); + assert(V->getType()->isPointerTy() && "Unexpected operand type!"); } while (1); } Value *Value::getUnderlyingObject(unsigned MaxLookup) { - if (!isa(getType())) + if (!getType()->isPointerTy()) return this; Value *V = this; for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) { @@ -357,7 +357,7 @@ } else { return V; } - assert(isa(V->getType()) && "Unexpected operand type!"); + assert(V->getType()->isPointerTy() && "Unexpected operand type!"); } return V; } Modified: llvm/trunk/lib/VMCore/ValueTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ValueTypes.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ValueTypes.cpp (original) +++ llvm/trunk/lib/VMCore/ValueTypes.cpp Tue Feb 16 05:11:14 2010 @@ -46,7 +46,7 @@ bool EVT::isExtendedVector() const { assert(isExtended() && "Type is not extended!"); - return isa(LLVMTy); + return LLVMTy->isVectorTy(); } bool EVT::isExtended64BitVector() const { Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Feb 16 05:11:14 2010 @@ -433,7 +433,7 @@ if (GV.hasAppendingLinkage()) { GlobalVariable *GVar = dyn_cast(&GV); - Assert1(GVar && isa(GVar->getType()->getElementType()), + Assert1(GVar && GVar->getType()->getElementType()->isArrayTy(), "Only global arrays can have appending linkage!", GVar); } } @@ -609,7 +609,7 @@ &F, FT); Assert1(F.getReturnType()->isFirstClassType() || F.getReturnType()->isVoidTy() || - isa(F.getReturnType()), + F.getReturnType()->isStructTy(), "Functions cannot return aggregate values!", &F); Assert1(!F.hasStructRetAttr() || F.getReturnType()->isVoidTy(), @@ -838,7 +838,7 @@ Assert1(SrcTy->isIntOrIntVectorTy(), "Trunc only operates on integer", &I); Assert1(DestTy->isIntOrIntVectorTy(), "Trunc only produces integer", &I); - Assert1(isa(SrcTy) == isa(DestTy), + Assert1(SrcTy->isVectorTy() == DestTy->isVectorTy(), "trunc source and destination must both be a vector or neither", &I); Assert1(SrcBitSize > DestBitSize,"DestTy too big for Trunc", &I); @@ -853,7 +853,7 @@ // Get the size of the types in bits, we'll need this later Assert1(SrcTy->isIntOrIntVectorTy(), "ZExt only operates on integer", &I); Assert1(DestTy->isIntOrIntVectorTy(), "ZExt only produces an integer", &I); - Assert1(isa(SrcTy) == isa(DestTy), + Assert1(SrcTy->isVectorTy() == DestTy->isVectorTy(), "zext source and destination must both be a vector or neither", &I); unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); unsigned DestBitSize = DestTy->getScalarSizeInBits(); @@ -874,7 +874,7 @@ Assert1(SrcTy->isIntOrIntVectorTy(), "SExt only operates on integer", &I); Assert1(DestTy->isIntOrIntVectorTy(), "SExt only produces an integer", &I); - Assert1(isa(SrcTy) == isa(DestTy), + Assert1(SrcTy->isVectorTy() == DestTy->isVectorTy(), "sext source and destination must both be a vector or neither", &I); Assert1(SrcBitSize < DestBitSize,"Type too small for SExt", &I); @@ -891,7 +891,7 @@ Assert1(SrcTy->isFPOrFPVectorTy(),"FPTrunc only operates on FP", &I); Assert1(DestTy->isFPOrFPVectorTy(),"FPTrunc only produces an FP", &I); - Assert1(isa(SrcTy) == isa(DestTy), + Assert1(SrcTy->isVectorTy() == DestTy->isVectorTy(), "fptrunc source and destination must both be a vector or neither",&I); Assert1(SrcBitSize > DestBitSize,"DestTy too big for FPTrunc", &I); @@ -909,7 +909,7 @@ Assert1(SrcTy->isFPOrFPVectorTy(),"FPExt only operates on FP", &I); Assert1(DestTy->isFPOrFPVectorTy(),"FPExt only produces an FP", &I); - Assert1(isa(SrcTy) == isa(DestTy), + Assert1(SrcTy->isVectorTy() == DestTy->isVectorTy(), "fpext source and destination must both be a vector or neither", &I); Assert1(SrcBitSize < DestBitSize,"DestTy too small for FPExt", &I); @@ -921,8 +921,8 @@ const Type *SrcTy = I.getOperand(0)->getType(); const Type *DestTy = I.getType(); - bool SrcVec = isa(SrcTy); - bool DstVec = isa(DestTy); + bool SrcVec = SrcTy->isVectorTy(); + bool DstVec = DestTy->isVectorTy(); Assert1(SrcVec == DstVec, "UIToFP source and dest must both be vector or scalar", &I); @@ -944,8 +944,8 @@ const Type *SrcTy = I.getOperand(0)->getType(); const Type *DestTy = I.getType(); - bool SrcVec = isa(SrcTy); - bool DstVec = isa(DestTy); + bool SrcVec = SrcTy->isVectorTy(); + bool DstVec = DestTy->isVectorTy(); Assert1(SrcVec == DstVec, "SIToFP source and dest must both be vector or scalar", &I); @@ -967,8 +967,8 @@ const Type *SrcTy = I.getOperand(0)->getType(); const Type *DestTy = I.getType(); - bool SrcVec = isa(SrcTy); - bool DstVec = isa(DestTy); + bool SrcVec = SrcTy->isVectorTy(); + bool DstVec = DestTy->isVectorTy(); Assert1(SrcVec == DstVec, "FPToUI source and dest must both be vector or scalar", &I); @@ -990,8 +990,8 @@ const Type *SrcTy = I.getOperand(0)->getType(); const Type *DestTy = I.getType(); - bool SrcVec = isa(SrcTy); - bool DstVec = isa(DestTy); + bool SrcVec = SrcTy->isVectorTy(); + bool DstVec = DestTy->isVectorTy(); Assert1(SrcVec == DstVec, "FPToSI source and dest must both be vector or scalar", &I); @@ -1013,7 +1013,7 @@ const Type *SrcTy = I.getOperand(0)->getType(); const Type *DestTy = I.getType(); - Assert1(isa(SrcTy), "PtrToInt source must be pointer", &I); + Assert1(SrcTy->isPointerTy(), "PtrToInt source must be pointer", &I); Assert1(DestTy->isIntegerTy(), "PtrToInt result must be integral", &I); visitInstruction(I); @@ -1025,7 +1025,7 @@ const Type *DestTy = I.getType(); Assert1(SrcTy->isIntegerTy(), "IntToPtr source must be an integral", &I); - Assert1(isa(DestTy), "IntToPtr result must be a pointer",&I); + Assert1(DestTy->isPointerTy(), "IntToPtr result must be a pointer",&I); visitInstruction(I); } @@ -1041,7 +1041,7 @@ // BitCast implies a no-op cast of type only. No bits change. // However, you can't cast pointers to anything but pointers. - Assert1(isa(DestTy) == isa(DestTy), + Assert1(DestTy->isPointerTy() == DestTy->isPointerTy(), "Bitcast requires both operands to be pointer or neither", &I); Assert1(SrcBitSize == DestBitSize, "Bitcast requires types of same width",&I); @@ -1084,11 +1084,11 @@ void Verifier::VerifyCallSite(CallSite CS) { Instruction *I = CS.getInstruction(); - Assert1(isa(CS.getCalledValue()->getType()), + Assert1(CS.getCalledValue()->getType()->isPointerTy(), "Called function must be a pointer!", I); const PointerType *FPTy = cast(CS.getCalledValue()->getType()); - Assert1(isa(FPTy->getElementType()), + Assert1(FPTy->getElementType()->isFunctionTy(), "Called function is not pointer to function type!", I); const FunctionType *FTy = cast(FPTy->getElementType()); @@ -1219,7 +1219,7 @@ Assert1(Op0Ty == Op1Ty, "Both operands to ICmp instruction are not of the same type!", &IC); // Check that the operands are the right type - Assert1(Op0Ty->isIntOrIntVectorTy() || isa(Op0Ty), + Assert1(Op0Ty->isIntOrIntVectorTy() || Op0Ty->isPointerTy(), "Invalid operand types for ICmp instruction", &IC); visitInstruction(IC); @@ -1286,7 +1286,7 @@ GetElementPtrInst::getIndexedType(GEP.getOperand(0)->getType(), Idxs.begin(), Idxs.end()); Assert1(ElTy, "Invalid indices for GEP pointer type!", &GEP); - Assert2(isa(GEP.getType()) && + Assert2(GEP.getType()->isPointerTy() && cast(GEP.getType())->getElementType() == ElTy, "GEP is not of right type for indices!", &GEP, ElTy); visitInstruction(GEP); @@ -1632,7 +1632,7 @@ if (ID == Intrinsic::gcroot) { AllocaInst *AI = dyn_cast(CI.getOperand(1)->stripPointerCasts()); - Assert1(AI && isa(AI->getType()->getElementType()), + Assert1(AI && AI->getType()->getElementType()->isPointerTy(), "llvm.gcroot parameter #1 must be a pointer alloca.", &CI); Assert1(isa(CI.getOperand(2)), "llvm.gcroot parameter #2 must be a constant.", &CI); @@ -1794,7 +1794,7 @@ } Suffix += ".v" + utostr(NumElts) + EVT::getEVT(EltTy).getEVTString(); } else if (VT == MVT::iPTR) { - if (!isa(Ty)) { + if (!Ty->isPointerTy()) { CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is not a " "pointer and a pointer is required.", F); return false; Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CrashDebugger.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/CrashDebugger.cpp (original) +++ llvm/trunk/tools/bugpoint/CrashDebugger.cpp Tue Feb 16 05:11:14 2010 @@ -295,7 +295,7 @@ TerminatorInst *BBTerm = BB->getTerminator(); - if (isa(BBTerm->getType())) + if (BBTerm->getType()->isStructTy()) BBTerm->replaceAllUsesWith(UndefValue::get(BBTerm->getType())); else if (BB->getTerminator()->getType() != Type::getVoidTy(BB->getContext())) Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=96344&r1=96343&r2=96344&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Tue Feb 16 05:11:14 2010 @@ -73,7 +73,7 @@ Instruction *TheInst = RI; // Got the corresponding instruction! // If this instruction produces a value, replace any users with null values - if (isa(TheInst->getType())) + if (TheInst->getType()->isStructTy()) TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType())); else if (TheInst->getType() != Type::getVoidTy(I->getContext())) TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType())); From baldrick at free.fr Tue Feb 16 06:10:34 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 12:10:34 -0000 Subject: [llvm-commits] [dragonegg] r96345 - /dragonegg/trunk/ Message-ID: <201002161210.o1GCAZQS013697@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 06:10:34 2010 New Revision: 96345 URL: http://llvm.org/viewvc/llvm-project?rev=96345&view=rev Log: Ignore dependency files (.d). These are auto-generated during the build. Modified: dragonegg/trunk/ (props changed) Propchange: dragonegg/trunk/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Tue Feb 16 06:10:34 2010 @@ -0,0 +1 @@ +*.d From baldrick at free.fr Tue Feb 16 06:26:56 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 12:26:56 -0000 Subject: [llvm-commits] [dragonegg] r96346 - in /dragonegg/trunk: llvm-abi-default.cpp llvm-backend.cpp llvm-convert.cpp x86/llvm-target.cpp Message-ID: <201002161226.o1GCQuRp014365@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 06:26:55 2010 New Revision: 96346 URL: http://llvm.org/viewvc/llvm-project?rev=96346&view=rev Log: There are two ways of checking for a given type, for example isa(T) and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. Modified: dragonegg/trunk/llvm-abi-default.cpp dragonegg/trunk/llvm-backend.cpp dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/x86/llvm-target.cpp Modified: dragonegg/trunk/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi-default.cpp?rev=96346&r1=96345&r2=96346&view=diff ============================================================================== --- dragonegg/trunk/llvm-abi-default.cpp (original) +++ dragonegg/trunk/llvm-abi-default.cpp Tue Feb 16 06:26:55 2010 @@ -11,7 +11,7 @@ void DefaultABI::HandleReturnType(tree type, tree fn, bool isBuiltin) { unsigned Offset = 0; const Type *Ty = ConvertType(type); - if (isa(Ty)) { + if (Ty->isVectorTy()) { // Vector handling is weird on x86. In particular builtin and // non-builtin function of the same return types can use different // calling conventions. @@ -81,7 +81,7 @@ const Type *PtrTy = Ty->getPointerTo(); C.HandleByInvisibleReferenceArgument(PtrTy, type); ScalarElts.push_back(PtrTy); - } else if (isa(Ty)) { + } else if (Ty->isVectorTy()) { if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) { PassInIntegerRegisters(type, ScalarElts, 0, false); } else if (LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(type)) { @@ -160,7 +160,7 @@ HandleUnion(type, ScalarElts); } else if (TREE_CODE(type) == ARRAY_TYPE) { // Array with padding? - if (isa(Ty)) + if (Ty->isStructTy()) Ty = cast(Ty)->getTypeAtIndex(0U); const ArrayType *ATy = cast(Ty); for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i) { Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=96346&r1=96345&r2=96346&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Tue Feb 16 06:26:55 2010 @@ -1651,7 +1651,7 @@ } FoundThis = true; // The current argument is 'this'. - assert(isa(AI->getType()) && "Wrong type for 'this'!"); + assert(AI->getType()->isPointerTy() && "Wrong type for 'this'!"); Value *This = AI; // Adjust 'this' according to the thunk offsets. First, the fixed offset. Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=96346&r1=96345&r2=96346&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Feb 16 06:26:55 2010 @@ -335,7 +335,7 @@ // Not clear what this is supposed to do on big endian machines... assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report"); // Do byte wise store because actual argument type does not match LLVMTy. - assert(isa(ArgVal->getType()) && "Expected an integer value!"); + assert(ArgVal->getType()->isIntegerTy() && "Expected an integer value!"); const Type *StoreType = IntegerType::get(Context, RealSize * 8); Loc = Builder.CreateBitCast(Loc, StoreType->getPointerTo()); if (ArgVal->getType()->getPrimitiveSizeInBits() >= @@ -442,7 +442,7 @@ unsigned RealSize = 0) { Value *ArgVal = AI; if (ArgVal->getType() != LLVMTy) { - if (isa(ArgVal->getType()) && isa(LLVMTy)) { + if (ArgVal->getType()->isPointerTy() && LLVMTy->isPointerTy()) { // If this is GCC being sloppy about pointer types, insert a bitcast. // See PR1083 for an example. ArgVal = Builder.CreateBitCast(ArgVal, LLVMTy); @@ -718,7 +718,7 @@ const Type *ArgTy = ConvertType(TREE_TYPE(Args)); bool isInvRef = isPassedByInvisibleReference(TREE_TYPE(Args)); if (isInvRef || - (isa(ArgTy) && + (ArgTy->isVectorTy() && LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(TREE_TYPE(Args))) || (!ArgTy->isSingleValueType() && isPassedByVal(TREE_TYPE(Args), ArgTy, ScalarArgs, @@ -1510,7 +1510,7 @@ const Type *Ty = *I; if (Ty->isFloatingPointTy()) return true; - if (isa(Ty) && containsFPField(Ty)) + if (Ty->isStructTy() && containsFPField(Ty)) return true; const ArrayType *ATy = dyn_cast(Ty); if (ATy && containsFPField(ATy->getElementType())) @@ -2344,7 +2344,7 @@ // Not clear what this is supposed to do on big endian machines... assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report"); - assert(isa(LLVMTy) && "Expected an integer value!"); + assert(LLVMTy->isIntegerTy() && "Expected an integer value!"); const Type *LoadType = IntegerType::get(Context, RealSize * 8); L = Builder.CreateBitCast(L, LoadType->getPointerTo()); Value *Val = Builder.CreateLoad(L); @@ -2722,7 +2722,7 @@ if (ConstantExpr *CE = dyn_cast(Callee)) { if (CallOperands.empty() && CE->getOpcode() == Instruction::BitCast) { Constant *RealCallee = CE->getOperand(0); - assert(isa(RealCallee->getType()) && + assert(RealCallee->getType()->isPointerTy() && "Bitcast to ptr not from ptr?"); const PointerType *RealPT = cast(RealCallee->getType()); if (const FunctionType *RealFT = @@ -3312,7 +3312,7 @@ /// Undef values may be specified by passing in -1 as the result value. /// Value *TreeToLLVM::BuildVectorShuffle(Value *InVec1, Value *InVec2, ...) { - assert(isa(InVec1->getType()) && + assert(InVec1->getType()->isVectorTy() && InVec1->getType() == InVec2->getType() && "Invalid shuffle!"); unsigned NumElements = cast(InVec1->getType())->getNumElements(); @@ -6816,8 +6816,8 @@ const Type *OTy = (Match < CallResultTypes.size()) ? CallResultTypes[Match] : 0; if (OTy && OTy != OpTy) { - if (!(isa(OTy) || isa(OTy)) || - !(isa(OpTy) || isa(OpTy))) { + if (!(OTy->isIntegerTy() || OTy->isPointerTy()) || + !(OpTy->isIntegerTy() || OpTy->isPointerTy())) { error_at(gimple_location(stmt), "unsupported inline asm: input constraint with a matching " "output constraint of incompatible type!"); @@ -7752,7 +7752,7 @@ Constant *RHS = Convert(TREE_OPERAND(exp, 1)); bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,1))); Instruction::CastOps opcode; - if (isa(LHS->getType())) { + if (LHS->getType()->isPointerTy()) { const Type *IntPtrTy = getTargetData().getIntPtrType(Context); opcode = CastInst::getCastOpcode(LHS, LHSIsSigned, IntPtrTy, false); LHS = TheFolder->CreateCast(opcode, LHS, IntPtrTy); Modified: dragonegg/trunk/x86/llvm-target.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/x86/llvm-target.cpp?rev=96346&r1=96345&r2=96346&view=diff ============================================================================== --- dragonegg/trunk/x86/llvm-target.cpp (original) +++ dragonegg/trunk/x86/llvm-target.cpp Tue Feb 16 06:26:55 2010 @@ -1296,7 +1296,7 @@ for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) { const Type *STy = I->get(); - if (!STy->isIntOrIntVectorTy() && !isa(STy)) + if (!STy->isIntOrIntVectorTy() && !STy->isPointerTy()) return false; } return true; @@ -1332,7 +1332,7 @@ EltTy == Type::getInt64Ty(Context) || EltTy == Type::getFloatTy(Context) || EltTy == Type::getDoubleTy(Context) || - isa(EltTy)) { + EltTy->isPointerTy()) { Elts.push_back(EltTy); continue; } @@ -1401,7 +1401,7 @@ else // All other vector scalar values are passed in XMM registers. ++NumXMMs; - } else if (Ty->isIntegerTy() || isa(Ty)) { + } else if (Ty->isIntegerTy() || Ty->isPointerTy()) { ++NumGPRs; } else if (Ty==Type::getVoidTy(Context)) { // Padding bytes that are not passed anywhere @@ -1996,7 +1996,7 @@ Idxs[1] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DestFieldNo); Idxs[2] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DestElemNo); Value *GEP = Builder.CreateGEP(Dest, Idxs, Idxs+3, "mrv_gep"); - if (isa(STy->getElementType(SrcFieldNo))) { + if (STy->getElementType(SrcFieldNo)->isVectorTy()) { Value *ElemIndex = ConstantInt::get(Type::getInt32Ty(Context), SrcElemNo); Value *EVIElem = Builder.CreateExtractElement(EVI, ElemIndex, "mrv"); Builder.CreateStore(EVIElem, GEP, isVolatile); @@ -2060,7 +2060,7 @@ } // Special treatement for _Complex. - if (isa(DestElemType)) { + if (DestElemType->isStructTy()) { llvm::Value *Idxs[3]; Idxs[0] = ConstantInt::get(llvm::Type::getInt32Ty(Context), 0); Idxs[1] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DNO); From baldrick at free.fr Tue Feb 16 06:37:42 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 12:37:42 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96347 - in /llvm-gcc-4.2/trunk/gcc: config/arm/llvm-arm.cpp config/i386/llvm-i386.cpp config/rs6000/llvm-rs6000.cpp cp/cfns.h llvm-abi-default.cpp llvm-convert.cpp Message-ID: <201002161237.o1GCbg9l014784@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 06:37:42 2010 New Revision: 96347 URL: http://llvm.org/viewvc/llvm-project?rev=96347&view=rev Log: There are two ways of checking for a given type, for example isa(T) and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp llvm-gcc-4.2/trunk/gcc/cp/cfns.h llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=96347&r1=96346&r2=96347&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Tue Feb 16 06:37:42 2010 @@ -2560,7 +2560,7 @@ default: assert(0); } - } else if (Ty->isIntegerTy() || isa(Ty) || + } else if (Ty->isIntegerTy() || Ty->isPointerTy() || Ty==Type::getVoidTy(Context)) { ; } else { @@ -2648,7 +2648,7 @@ Idxs[1] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DestFieldNo); Idxs[2] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DestElemNo); Value *GEP = Builder.CreateGEP(Dest, Idxs, Idxs+3, "mrv_gep"); - if (isa(STy->getElementType(SrcFieldNo))) { + if (STy->getElementType(SrcFieldNo)->isVectorTy()) { Value *ElemIndex = ConstantInt::get(Type::getInt32Ty(Context), SrcElemNo); Value *EVIElem = Builder.CreateExtractElement(EVI, ElemIndex, "mrv"); Builder.CreateStore(EVIElem, GEP, isVolatile); Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=96347&r1=96346&r2=96347&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Tue Feb 16 06:37:42 2010 @@ -655,7 +655,7 @@ for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) { const Type *STy = I->get(); - if (!STy->isIntOrIntVectorTy() && !isa(STy)) + if (!STy->isIntOrIntVectorTy() && !STy->isPointerTy()) return false; } return true; @@ -688,7 +688,7 @@ // (which can be picked as the type for a union of 16 bytes) is not fine, // as loads and stores of it get only 10 bytes. if (EltTy->isIntegerTy(32) || EltTy->isIntegerTy(64) || - EltTy->isFloatTy() || EltTy->isDoubleTy() || isa(EltTy)) { + EltTy->isFloatTy() || EltTy->isDoubleTy() || EltTy->isPointerTy()) { Elts.push_back(EltTy); continue; } @@ -757,7 +757,7 @@ else // All other vector scalar values are passed in XMM registers. ++NumXMMs; - } else if (Ty->isIntegerTy() || isa(Ty)) { + } else if (Ty->isIntegerTy() || Ty->isPointerTy()) { ++NumGPRs; } else if (Ty->isVoidTy()) { // Padding bytes that are not passed anywhere @@ -1374,7 +1374,7 @@ Idxs[1] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DestFieldNo); Idxs[2] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DestElemNo); Value *GEP = Builder.CreateGEP(Dest, Idxs, Idxs+3, "mrv_gep"); - if (isa(STy->getElementType(SrcFieldNo))) { + if (STy->getElementType(SrcFieldNo)->isVectorTy()) { Value *ElemIndex = ConstantInt::get(Type::getInt32Ty(Context), SrcElemNo); Value *EVIElem = Builder.CreateExtractElement(EVI, ElemIndex, "mrv"); Builder.CreateStore(EVIElem, GEP, isVolatile); @@ -1438,7 +1438,7 @@ } // Special treatement for _Complex. - if (isa(DestElemType)) { + if (DestElemType->isStructTy()) { llvm::Value *Idxs[3]; Idxs[0] = ConstantInt::get(llvm::Type::getInt32Ty(Context), 0); Idxs[1] = ConstantInt::get(llvm::Type::getInt32Ty(Context), DNO); Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=96347&r1=96346&r2=96347&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Tue Feb 16 06:37:42 2010 @@ -395,7 +395,7 @@ const Type *Ty = ScalarElts[i]; if (const VectorType *VTy = dyn_cast(Ty)) { abort(); - } else if (isa(Ty)) { + } else if (Ty->isPointerTy()) { NumGPRs++; } else if (Ty->isIntegerTy()) { unsigned TypeSize = Ty->getPrimitiveSizeInBits(); @@ -453,8 +453,8 @@ } } } else if (!(Ty->isFloatingPointTy() || - isa(Ty) || - isa(Ty))) { + Ty->isVectorTy() || + Ty->isPointerTy())) { abort(); } Modified: llvm-gcc-4.2/trunk/gcc/cp/cfns.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/cfns.h?rev=96347&r1=96346&r2=96347&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cp/cfns.h (original) +++ llvm-gcc-4.2/trunk/gcc/cp/cfns.h Tue Feb 16 06:37:42 2010 @@ -1,5 +1,5 @@ -/* ANSI-C code produced by gperf version 3.0.1 */ -/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C ../../gcc/gcc/cp/cfns.gperf */ +/* ANSI-C code produced by gperf version 3.0.3 */ +/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C ../../gcc-4.2.llvm/gcc/cp/cfns.gperf */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -28,7 +28,7 @@ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif -#line 1 "../../gcc/gcc/cp/cfns.gperf" +#line 1 "../../gcc-4.2.llvm/gcc/cp/cfns.gperf" #ifdef __GNUC__ __inline @@ -57,13 +57,13 @@ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 0, 0, - 1, 400, 400, 400, 400, 400, 400, 400, 400, 400, + 1, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 28, 90, 0, 95, 0, 51, 93, 114, 26, 109, 124, 5, 1, - 6, 13, 37, 128, 3, 0, 0, 49, 38, 0, + 6, 13, 37, 128, 3, 0, 0, 49, 38, 0, 104, 45, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, @@ -84,29 +84,32 @@ switch (hval) { default: - hval += asso_values[(unsigned char)str[5]+1]; + hval += asso_values[(unsigned char)str[5]+1]; /*FALLTHROUGH*/ case 5: - hval += asso_values[(unsigned char)str[4]]; + hval += asso_values[(unsigned char)str[4]]; /*FALLTHROUGH*/ case 4: - hval += asso_values[(unsigned char)str[3]]; + hval += asso_values[(unsigned char)str[3]]; /*FALLTHROUGH*/ case 3: - hval += asso_values[(unsigned char)str[2]]; + hval += asso_values[(unsigned char)str[2]]; /*FALLTHROUGH*/ case 2: - hval += asso_values[(unsigned char)str[1]]; + hval += asso_values[(unsigned char)str[1]]; /*FALLTHROUGH*/ case 1: - hval += asso_values[(unsigned char)str[0]]; - break; + hval += asso_values[(unsigned char)str[0]]; + break; } return hval + asso_values[(unsigned char)str[len - 1]]; } #ifdef __GNUC__ __inline +#ifdef __GNUC_STDC_INLINE__ +__attribute__ ((__gnu_inline__)) +#endif #endif const char * libc_name_p (register const char *str, register unsigned int len) @@ -329,17 +332,17 @@ register int key = hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) - { - register int index = lookup[key]; + { + register int index = lookup[key]; - if (index >= 0) - { - register const char *s = wordlist[index]; - - if (*str == *s && !strcmp (str + 1, s + 1)) - return s; - } - } + if (index >= 0) + { + register const char *s = wordlist[index]; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return s; + } + } } return 0; } Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp?rev=96347&r1=96346&r2=96347&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp Tue Feb 16 06:37:42 2010 @@ -11,7 +11,7 @@ void DefaultABI::HandleReturnType(tree type, tree fn, bool isBuiltin) { unsigned Offset = 0; const Type *Ty = ConvertType(type); - if (isa(Ty)) { + if (Ty->isVectorTy()) { // Vector handling is weird on x86. In particular builtin and // non-builtin function of the same return types can use different // calling conventions. @@ -78,7 +78,7 @@ const Type *PtrTy = Ty->getPointerTo(); C.HandleByInvisibleReferenceArgument(PtrTy, type); ScalarElts.push_back(PtrTy); - } else if (isa(Ty)) { + } else if (Ty->isVectorTy()) { if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) { PassInIntegerRegisters(type, ScalarElts, 0, false); } else if (LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(type)) { Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=96347&r1=96346&r2=96347&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Feb 16 06:37:42 2010 @@ -223,7 +223,7 @@ // Not clear what this is supposed to do on big endian machines... assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report"); // Do byte wise store because actual argument type does not match LLVMTy. - assert(isa(ArgVal->getType()) && "Expected an integer value!"); + assert(ArgVal->getType()->isIntegerTy() && "Expected an integer value!"); const Type *StoreType = IntegerType::get(Context, RealSize * 8); Loc = Builder.CreateBitCast(Loc, StoreType->getPointerTo()); if (ArgVal->getType()->getPrimitiveSizeInBits() >= @@ -334,7 +334,7 @@ unsigned RealSize = 0) { Value *ArgVal = AI; if (ArgVal->getType() != LLVMTy) { - if (isa(ArgVal->getType()) && isa(LLVMTy)) { + if (ArgVal->getType()->isPointerTy() && LLVMTy->isPointerTy()) { // If this is GCC being sloppy about pointer types, insert a bitcast. // See PR1083 for an example. ArgVal = Builder.CreateBitCast(ArgVal, LLVMTy); @@ -642,7 +642,7 @@ const Type *ArgTy = ConvertType(TREE_TYPE(Args)); bool isInvRef = isPassedByInvisibleReference(TREE_TYPE(Args)); if (isInvRef || - (isa(ArgTy) && + (ArgTy->isVectorTy() && LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(TREE_TYPE(Args))) || (!ArgTy->isSingleValueType() && isPassedByVal(TREE_TYPE(Args), ArgTy, ScalarArgs, @@ -1130,7 +1130,7 @@ // FIXME: The vector stuff isn't straight-forward. Sometimes X86 can // pass it back as a scalar value. Disable checking if it's a // vector. This should be made better, though. - isa(ConvertType(TREE_TYPE(exp))) || + ConvertType(TREE_TYPE(exp))->isVectorTy() || // FIXME: The handling of MODIFY_EXPR doesn't always produce results // that pass this check; the return type might be the LHS type or // the RHS type, neither of which is guaranteed to be the @@ -1447,7 +1447,7 @@ const Type *Ty = *I; if (Ty->isFloatingPointTy()) return true; - if (isa(Ty) && containsFPField(Ty)) + if (Ty->isStructTy() && containsFPField(Ty)) return true; const ArrayType *ATy = dyn_cast(Ty); if (ATy && containsFPField(ATy->getElementType())) @@ -2520,7 +2520,7 @@ // Not clear what this is supposed to do on big endian machines... assert(!BYTES_BIG_ENDIAN && "Unsupported case - please report"); - assert(isa(LLVMTy) && "Expected an integer value!"); + assert(LLVMTy->isIntegerTy() && "Expected an integer value!"); const Type *LoadType = IntegerType::get(Context, RealSize * 8); L = Builder.CreateBitCast(L, LoadType->getPointerTo()); Value *Val = Builder.CreateLoad(L); @@ -2888,7 +2888,7 @@ if (ConstantExpr *CE = dyn_cast(Callee)) { if (CallOperands.empty() && CE->getOpcode() == Instruction::BitCast) { Constant *RealCallee = CE->getOperand(0); - assert(isa(RealCallee->getType()) && + assert(RealCallee->getType()->isPointerTy() && "Bitcast to ptr not from ptr?"); const PointerType *RealPT = cast(RealCallee->getType()); if (const FunctionType *RealFT = @@ -3312,15 +3312,15 @@ // If the source is a pointer, use ptrtoint to get it to something // bitcast'able. This supports things like v_c_e(foo*, float). - if (isa(OpVal->getType())) { - if (isa(DestTy)) // ptr->ptr is a simple bitcast. + if (OpVal->getType()->isPointerTy()) { + if (DestTy->isPointerTy()) // ptr->ptr is a simple bitcast. return Builder.CreateBitCast(OpVal, DestTy); // Otherwise, ptrtoint to intptr_t first. OpVal = Builder.CreatePtrToInt(OpVal, TD.getIntPtrType(Context)); } // If the destination type is a pointer, use inttoptr. - if (isa(DestTy)) + if (DestTy->isPointerTy()) return Builder.CreateIntToPtr(OpVal, DestTy); // Otherwise, use a bitcast. @@ -3332,7 +3332,7 @@ Value *V = Emit(TREE_OPERAND(exp, 0), 0); if (V->getType()->isFPOrFPVectorTy()) return Builder.CreateFNeg(V); - if (!isa(V->getType())) { + if (!V->getType()->isPointerTy()) { bool HasNSW = !TYPE_OVERFLOW_WRAPS(TREE_TYPE(exp)); return HasNSW ? Builder.CreateNSWNeg(V) : Builder.CreateNeg(V); } @@ -3430,13 +3430,13 @@ Value *TreeToLLVM::EmitBIT_NOT_EXPR(tree exp) { Value *Op = Emit(TREE_OPERAND(exp, 0), 0); const Type *Ty = Op->getType(); - if (isa(Ty)) { + if (Ty->isPointerTy()) { assert (TREE_CODE(TREE_TYPE(exp)) == INTEGER_TYPE && "Expected integer type here"); Ty = ConvertType(TREE_TYPE(exp)); Op = CastToType(Instruction::PtrToInt, Op, Ty); } else if (Ty->isFloatingPointTy() || - (isa(Ty) && + (Ty->isVectorTy() && cast(Ty)->getElementType()->isFloatingPointTy())) { Op = BitCastToType(Op, getSuitableBitCastIntType(Ty)); } @@ -3509,9 +3509,9 @@ /// Value *TreeToLLVM::EmitBinOp(tree exp, const MemRef *DestLoc, unsigned Opc) { const Type *Ty = ConvertType(TREE_TYPE(exp)); - if (isa(Ty)) + if (Ty->isPointerTy()) return EmitPtrBinOp(exp, Opc); // Pointer arithmetic! - if (isa(Ty)) + if (Ty->isStructTy()) return EmitComplexBinOp(exp, DestLoc); assert(Ty->isSingleValueType() && DestLoc == 0 && "Bad binary operation!"); @@ -3537,7 +3537,7 @@ const Type *ResTy = Ty; if (isLogicalOp && (Ty->isFloatingPointTy() || - (isa(Ty) && + (Ty->isVectorTy() && cast(Ty)->getElementType()->isFloatingPointTy()))) { Ty = getSuitableBitCastIntType(Ty); LHS = BitCastToType(LHS, Ty); @@ -3632,7 +3632,7 @@ Value *TreeToLLVM::EmitShiftOp(tree exp, const MemRef *DestLoc, unsigned Opc) { assert(DestLoc == 0 && "aggregate shift?"); const Type *Ty = ConvertType(TREE_TYPE(exp)); - assert(!isa(Ty) && "Pointer arithmetic!?"); + assert(!Ty->isPointerTy() && "Pointer arithmetic!?"); Value *LHS = Emit(TREE_OPERAND(exp, 0), 0); Value *RHS = Emit(TREE_OPERAND(exp, 1), 0); @@ -3647,7 +3647,7 @@ Value *In = Emit(TREE_OPERAND(exp, 0), 0); Value *Amt = Emit(TREE_OPERAND(exp, 1), 0); - if (isa(In->getType())) { + if (In->getType()->isPointerTy()) { const Type *Ty = IntegerType::get(Context, TYPE_PRECISION(TREE_TYPE (TREE_OPERAND (exp, 0)))); @@ -4641,8 +4641,8 @@ const Type *OTy = (Match < CallResultTypes.size()) ? CallResultTypes[Match] : 0; if (OTy && OTy != OpTy) { - if (!(isa(OTy) || isa(OTy)) || - !(isa(OpTy) || isa(OpTy))) { + if (!(OTy->isIntegerTy() || OTy->isPointerTy()) || + !(OpTy->isIntegerTy() || OpTy->isPointerTy())) { error("%Hunsupported inline asm: input constraint with a matching " "output constraint of incompatible type!", &EXPR_LOCATION(exp)); @@ -4861,7 +4861,7 @@ /// Undef values may be specified by passing in -1 as the result value. /// Value *TreeToLLVM::BuildVectorShuffle(Value *InVec1, Value *InVec2, ...) { - assert(isa(InVec1->getType()) && + assert(InVec1->getType()->isVectorTy() && InVec1->getType() == InVec2->getType() && "Invalid shuffle!"); unsigned NumElements = cast(InVec1->getType())->getNumElements(); @@ -7607,7 +7607,7 @@ Constant *RHS = Convert(TREE_OPERAND(exp, 1)); bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,1))); Instruction::CastOps opcode; - if (isa(LHS->getType())) { + if (LHS->getType()->isPointerTy()) { const Type *IntPtrTy = getTargetData().getIntPtrType(Context); opcode = CastInst::getCastOpcode(LHS, LHSIsSigned, IntPtrTy, false); LHS = TheFolder->CreateCast(opcode, LHS, IntPtrTy); From baldrick at free.fr Tue Feb 16 06:48:01 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 12:48:01 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96348 - /llvm-gcc-4.2/trunk/gcc/cp/cfns.h Message-ID: <201002161248.o1GCm22f015277@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 06:48:01 2010 New Revision: 96348 URL: http://llvm.org/viewvc/llvm-project?rev=96348&view=rev Log: Revert unintended commit. Modified: llvm-gcc-4.2/trunk/gcc/cp/cfns.h Modified: llvm-gcc-4.2/trunk/gcc/cp/cfns.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/cfns.h?rev=96348&r1=96347&r2=96348&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cp/cfns.h (original) +++ llvm-gcc-4.2/trunk/gcc/cp/cfns.h Tue Feb 16 06:48:01 2010 @@ -1,5 +1,5 @@ -/* ANSI-C code produced by gperf version 3.0.3 */ -/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C ../../gcc-4.2.llvm/gcc/cp/cfns.gperf */ +/* ANSI-C code produced by gperf version 3.0.1 */ +/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C ../../gcc/gcc/cp/cfns.gperf */ #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ @@ -28,7 +28,7 @@ #error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif -#line 1 "../../gcc-4.2.llvm/gcc/cp/cfns.gperf" +#line 1 "../../gcc/gcc/cp/cfns.gperf" #ifdef __GNUC__ __inline @@ -57,13 +57,13 @@ 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 0, 0, - 1, 400, 400, 400, 400, 400, 400, 400, 400, 400, + 1, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 28, 90, 0, 95, 0, 51, 93, 114, 26, 109, 124, 5, 1, - 6, 13, 37, 128, 3, 0, 0, 49, 38, 0, + 6, 13, 37, 128, 3, 0, 0, 49, 38, 0, 104, 45, 0, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, @@ -84,32 +84,29 @@ switch (hval) { default: - hval += asso_values[(unsigned char)str[5]+1]; + hval += asso_values[(unsigned char)str[5]+1]; /*FALLTHROUGH*/ case 5: - hval += asso_values[(unsigned char)str[4]]; + hval += asso_values[(unsigned char)str[4]]; /*FALLTHROUGH*/ case 4: - hval += asso_values[(unsigned char)str[3]]; + hval += asso_values[(unsigned char)str[3]]; /*FALLTHROUGH*/ case 3: - hval += asso_values[(unsigned char)str[2]]; + hval += asso_values[(unsigned char)str[2]]; /*FALLTHROUGH*/ case 2: - hval += asso_values[(unsigned char)str[1]]; + hval += asso_values[(unsigned char)str[1]]; /*FALLTHROUGH*/ case 1: - hval += asso_values[(unsigned char)str[0]]; - break; + hval += asso_values[(unsigned char)str[0]]; + break; } return hval + asso_values[(unsigned char)str[len - 1]]; } #ifdef __GNUC__ __inline -#ifdef __GNUC_STDC_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif #endif const char * libc_name_p (register const char *str, register unsigned int len) @@ -332,17 +329,17 @@ register int key = hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) - { - register int index = lookup[key]; + { + register int index = lookup[key]; - if (index >= 0) - { - register const char *s = wordlist[index]; - - if (*str == *s && !strcmp (str + 1, s + 1)) - return s; - } - } + if (index >= 0) + { + register const char *s = wordlist[index]; + + if (*str == *s && !strcmp (str + 1, s + 1)) + return s; + } + } } return 0; } From baldrick at free.fr Tue Feb 16 08:50:10 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 14:50:10 -0000 Subject: [llvm-commits] [llvm] r96349 - in /llvm/trunk: include/llvm/Type.h lib/AsmParser/LLParser.cpp lib/Linker/LinkModules.cpp lib/Target/CBackend/CBackend.cpp lib/Target/MSIL/MSILWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/ConstantFold.cpp lib/VMCore/Function.cpp lib/VMCore/Type.cpp lib/VMCore/Value.cpp Message-ID: <201002161450.o1GEoAxq020821@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 08:50:09 2010 New Revision: 96349 URL: http://llvm.org/viewvc/llvm-project?rev=96349&view=rev Log: Introduce isOpaqueTy and use it rather than isa. Also, move some methods to try to have the type predicates be more logically positioned. Modified: llvm/trunk/include/llvm/Type.h llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Linker/LinkModules.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/MSIL/MSILWriter.cpp llvm/trunk/lib/VMCore/AsmWriter.cpp llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Tue Feb 16 08:50:09 2010 @@ -182,6 +182,9 @@ // are defined in private classes defined in Type.cpp for primitive types. // + /// getDescription - Return the string representation of the type. + std::string getDescription() const; + /// getTypeID - Return the type id for the type. This will return one /// of the TypeID enum elements defined above. /// @@ -205,15 +208,21 @@ /// isPPC_FP128Ty - Return true if this is powerpc long double. bool isPPC_FP128Ty() const { return ID == PPC_FP128TyID; } + /// isFloatingPointTy - Return true if this is one of the five floating point + /// types + bool isFloatingPointTy() const { return ID == FloatTyID || ID == DoubleTyID || + ID == X86_FP80TyID || ID == FP128TyID || ID == PPC_FP128TyID; } + + /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP. + /// + bool isFPOrFPVectorTy() const; + /// isLabelTy - Return true if this is 'label'. bool isLabelTy() const { return ID == LabelTyID; } /// isMetadataTy - Return true if this is 'metadata'. bool isMetadataTy() const { return ID == MetadataTyID; } - /// getDescription - Return the string representation of the type. - std::string getDescription() const; - /// isIntegerTy - True if this is an instance of IntegerType. /// bool isIntegerTy() const { return ID == IntegerTyID; } @@ -226,15 +235,6 @@ /// bool isIntOrIntVectorTy() const; - /// isFloatingPointTy - Return true if this is one of the five floating point - /// types - bool isFloatingPointTy() const { return ID == FloatTyID || ID == DoubleTyID || - ID == X86_FP80TyID || ID == FP128TyID || ID == PPC_FP128TyID; } - - /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP. - /// - bool isFPOrFPVectorTy() const; - /// isFunctionTy - True if this is an instance of FunctionType. /// bool isFunctionTy() const { return ID == FunctionTyID; } @@ -255,6 +255,10 @@ /// bool isPointerTy() const { return ID == PointerTyID; } + /// isOpaqueTy - True if this is an instance of OpaqueType. + /// + bool isOpaqueTy() const { return ID == OpaqueTyID; } + /// isVectorTy - True if this is an instance of VectorType. /// bool isVectorTy() const { return ID == VectorTyID; } Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Feb 16 08:50:09 2010 @@ -791,7 +791,7 @@ GlobalValue *FwdVal; if (const FunctionType *FT = dyn_cast(PTy->getElementType())) { // Function types can return opaque but functions can't. - if (isa(FT->getReturnType())) { + if (FT->getReturnType()->isOpaqueTy()) { Error(Loc, "function may not return opaque type"); return 0; } @@ -836,7 +836,7 @@ GlobalValue *FwdVal; if (const FunctionType *FT = dyn_cast(PTy->getElementType())) { // Function types can return opaque but functions can't. - if (isa(FT->getReturnType())) { + if (FT->getReturnType()->isOpaqueTy()) { Error(Loc, "function may not return opaque type"); return 0; } @@ -1515,7 +1515,7 @@ Name = ""; } - if (!ArgTy->isFirstClassType() && !isa(ArgTy)) + if (!ArgTy->isFirstClassType() && !ArgTy->isOpaqueTy()) return Error(TypeLoc, "invalid type for function argument"); ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attrs, Name)); @@ -1785,7 +1785,7 @@ } // Don't make placeholders with invalid type. - if (!Ty->isFirstClassType() && !isa(Ty) && !Ty->isLabelTy()) { + if (!Ty->isFirstClassType() && !Ty->isOpaqueTy() && !Ty->isLabelTy()) { P.Error(Loc, "invalid use of a non-first-class type"); return 0; } @@ -1826,7 +1826,7 @@ return 0; } - if (!Ty->isFirstClassType() && !isa(Ty) && !Ty->isLabelTy()) { + if (!Ty->isFirstClassType() && !Ty->isOpaqueTy() && !Ty->isLabelTy()) { P.Error(Loc, "invalid use of a non-first-class type"); return 0; } @@ -2542,7 +2542,7 @@ case ValID::t_Undef: // FIXME: LabelTy should not be a first-class type. if ((!Ty->isFirstClassType() || Ty->isLabelTy()) && - !isa(Ty)) + !Ty->isOpaqueTy()) return Error(ID.Loc, "invalid type for undef constant"); V = UndefValue::get(Ty); return false; @@ -2662,7 +2662,7 @@ } if (!FunctionType::isValidReturnType(RetType) || - isa(RetType)) + RetType->isOpaqueTy()) return Error(RetTypeLoc, "invalid function return type"); LocTy NameLoc = Lex.getLoc(); Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Feb 16 08:50:09 2010 @@ -159,7 +159,7 @@ if (DstTy == SrcTy) return false; // If already equal, noop // If we found our opaque type, resolve it now! - if (isa(DstTy) || isa(SrcTy)) + if (DstTy->isOpaqueTy() || SrcTy->isOpaqueTy()) return ResolveTypes(DstTy, SrcTy); // Two types cannot be resolved together if they are of different primitive Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Feb 16 08:50:09 2010 @@ -385,7 +385,7 @@ // If this isn't a struct or array type, remove it from our set of types // to name. This simplifies emission later. - if (!I->second->isStructTy() && !isa(I->second) && + if (!I->second->isStructTy() && !I->second->isOpaqueTy() && !I->second->isArrayTy()) { TST.remove(I); } else { @@ -597,7 +597,7 @@ } // Check to see if the type is named. - if (!IgnoreName || isa(Ty)) { + if (!IgnoreName || Ty->isOpaqueTy()) { std::map::iterator I = TypeNames.find(Ty); if (I != TypeNames.end()) return Out << I->second << ' ' << NameSoFar; } @@ -700,7 +700,7 @@ } // Check to see if the type is named. - if (!IgnoreName || isa(Ty)) { + if (!IgnoreName || Ty->isOpaqueTy()) { std::map::iterator I = TypeNames.find(Ty); if (I != TypeNames.end()) return Out << I->second << ' ' << NameSoFar; } Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Tue Feb 16 08:50:09 2010 @@ -57,7 +57,7 @@ TypeSymbolTable& Table = M.getTypeSymbolTable(); std::set Types = getAnalysis().getTypes(); for (TypeSymbolTable::iterator I = Table.begin(), E = Table.end(); I!=E; ) { - if (!I->second->isStructTy() && !isa(I->second)) + if (!I->second->isStructTy() && !I->second->isOpaqueTy()) Table.remove(I++); else { std::set::iterator T = Types.find(I->second); Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Feb 16 08:50:09 2010 @@ -377,7 +377,7 @@ // If this is a structure or opaque type, add a name for the type. if (((Ty->isStructTy() && cast(Ty)->getNumElements()) - || isa(Ty)) && !TP.hasTypeName(Ty)) { + || Ty->isOpaqueTy()) && !TP.hasTypeName(Ty)) { TP.addTypeName(Ty, "%"+utostr(unsigned(NumberedTypes.size()))); NumberedTypes.push_back(Ty); } @@ -432,7 +432,7 @@ if (const PointerType *PTy = dyn_cast(Ty)) { const Type *PETy = PTy->getElementType(); if ((PETy->isPrimitiveType() || PETy->isIntegerTy()) && - !isa(PETy)) + !PETy->isOpaqueTy()) continue; } Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Feb 16 08:50:09 2010 @@ -1427,7 +1427,7 @@ /// isZeroSizedType - This type is zero sized if its an array or structure of /// zero sized types. The only leaf zero sized type is an empty structure. static bool isMaybeZeroSizedType(const Type *Ty) { - if (isa(Ty)) return true; // Can't say. + if (Ty->isOpaqueTy()) return true; // Can't say. if (const StructType *STy = dyn_cast(Ty)) { // If all of elements have zero size, this does too. Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Tue Feb 16 08:50:09 2010 @@ -155,7 +155,7 @@ : GlobalValue(PointerType::getUnqual(Ty), Value::FunctionVal, 0, 0, Linkage, name) { assert(FunctionType::isValidReturnType(getReturnType()) && - !isa(getReturnType()) && "invalid return type"); + !getReturnType()->isOpaqueTy() && "invalid return type"); SymTab = new ValueSymbolTable(); // If the function has arguments, mark them as lazily built. Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Feb 16 08:50:09 2010 @@ -447,7 +447,7 @@ /// isValidArgumentType - Return true if the specified type is valid as an /// argument type. bool FunctionType::isValidArgumentType(const Type *ArgTy) { - return ArgTy->isFirstClassType() || isa(ArgTy); + return ArgTy->isFirstClassType() || ArgTy->isOpaqueTy(); } FunctionType::FunctionType(const Type *Result, @@ -613,7 +613,7 @@ // Concrete types are leaves in the tree. Since an SCC will either be all // abstract or all concrete, we only need to check one type. if (SCC[0]->isAbstract()) { - if (isa(SCC[0])) + if (SCC[0]->isOpaqueTy()) return; // Not going to be concrete, sorry. // If all of the children of all of the types in this SCC are concrete, @@ -660,7 +660,7 @@ std::map &EqTypes) { if (Ty == Ty2) return true; if (Ty->getTypeID() != Ty2->getTypeID()) return false; - if (isa(Ty)) + if (Ty->isOpaqueTy()) return false; // Two unequal opaque types are never equal std::map::iterator It = EqTypes.find(Ty); @@ -912,7 +912,7 @@ bool VectorType::isValidElementType(const Type *ElemTy) { return ElemTy->isIntegerTy() || ElemTy->isFloatingPointTy() || - isa(ElemTy); + ElemTy->isOpaqueTy(); } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=96349&r1=96348&r2=96349&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Tue Feb 16 08:50:09 2010 @@ -45,11 +45,11 @@ UseList(0), Name(0) { if (isa(this) || isa(this)) assert((VTy->isFirstClassType() || VTy->isVoidTy() || - isa(ty) || VTy->isStructTy()) && + ty->isOpaqueTy() || VTy->isStructTy()) && "invalid CallInst type!"); else if (!isa(this) && !isa(this)) assert((VTy->isFirstClassType() || VTy->isVoidTy() || - isa(ty)) && + ty->isOpaqueTy()) && "Cannot create non-first-class values except for constants!"); } From baldrick at free.fr Tue Feb 16 09:15:11 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 15:15:11 -0000 Subject: [llvm-commits] [dragonegg] r96350 - /dragonegg/trunk/llvm-types.cpp Message-ID: <201002161515.o1GFFCDp022082@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 09:15:11 2010 New Revision: 96350 URL: http://llvm.org/viewvc/llvm-project?rev=96350&view=rev Log: Use isOpaqueTy rather than isa. Modified: dragonegg/trunk/llvm-types.cpp Modified: dragonegg/trunk/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-types.cpp?rev=96350&r1=96349&r2=96350&view=diff ============================================================================== --- dragonegg/trunk/llvm-types.cpp (original) +++ dragonegg/trunk/llvm-types.cpp Tue Feb 16 09:15:11 2010 @@ -742,7 +742,7 @@ // of the vector. Remove this entry from the PointersToReresolve list and // get the pointee type. Note that this order is important in case the // pointee type uses this pointer. - assert(isa(PTy->getElementType()) && "Not a deferred ref!"); + assert(PTy->getElementType()->isOpaqueTy() && "Not a deferred ref!"); // We are actively resolving this pointer. We want to pop this value from // the stack, as we are no longer resolving it. However, we don't want to @@ -1165,7 +1165,7 @@ for (; Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)){ tree ArgTy = TREE_VALUE(Args); if (!isPassedByInvisibleReference(ArgTy) && - isa(ConvertType(ArgTy))) { + ConvertType(ArgTy)->isOpaqueTy()) { // If we are passing an opaque struct by value, we don't know how many // arguments it will turn into. Because we can't handle this yet, // codegen the prototype as (...). @@ -1927,7 +1927,7 @@ if (const Type *Ty = GET_TYPE_LLVM(type)) { // If we already compiled this type, and if it was not a forward // definition that is now defined, use the old type. - if (!isa(Ty) || TYPE_SIZE(type) == 0) + if (!Ty->isOpaqueTy() || TYPE_SIZE(type) == 0) return Ty; } From baldrick at free.fr Tue Feb 16 10:23:36 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Feb 2010 16:23:36 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96353 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Message-ID: <201002161623.o1GGNa27025408@zion.cs.uiuc.edu> Author: baldrick Date: Tue Feb 16 10:23:36 2010 New Revision: 96353 URL: http://llvm.org/viewvc/llvm-project?rev=96353&view=rev Log: Use isOpaqueTy rather than isa. Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=96353&r1=96352&r2=96353&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Tue Feb 16 10:23:36 2010 @@ -772,7 +772,7 @@ // of the vector. Remove this entry from the PointersToReresolve list and // get the pointee type. Note that this order is important in case the // pointee type uses this pointer. - assert(isa(Ty->getElementType()) && "Not a deferred ref!"); + assert(Ty->getElementType()->isOpaqueTy() && "Not a deferred ref!"); // We are actively resolving this pointer. We want to pop this value from // the stack, as we are no longer resolving it. However, we don't want to @@ -1210,7 +1210,7 @@ for (; Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)){ tree ArgTy = TREE_VALUE(Args); if (!isPassedByInvisibleReference(ArgTy) && - isa(ConvertType(ArgTy))) { + ConvertType(ArgTy)->isOpaqueTy()) { // If we are passing an opaque struct by value, we don't know how many // arguments it will turn into. Because we can't handle this yet, // codegen the prototype as (...). @@ -2134,7 +2134,7 @@ if (const Type *Ty = GET_TYPE_LLVM(type)) { // If we already compiled this type, and if it was not a forward // definition that is now defined, use the old type. - if (!isa(Ty) || TYPE_SIZE(type) == 0) + if (!Ty->isOpaqueTy() || TYPE_SIZE(type) == 0) return Ty; } From bob.wilson at apple.com Tue Feb 16 11:24:16 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Feb 2010 17:24:16 -0000 Subject: [llvm-commits] [llvm] r96360 - in /llvm/trunk: lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMInstrInfo.td test/CodeGen/ARM/call.ll Message-ID: <201002161724.o1GHOG2k029111@zion.cs.uiuc.edu> Author: bwilson Date: Tue Feb 16 11:24:15 2010 New Revision: 96360 URL: http://llvm.org/viewvc/llvm-project?rev=96360&view=rev Log: Fix pr6111: Avoid using the LR register for the target address of an indirect branch in ARM v4 code, since it gets clobbered by the return address before it is used. Instead of adding a new register class containing all the GPRs except LR, just use the existing tGPR class. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/test/CodeGen/ARM/call.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=96360&r1=96359&r2=96360&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Feb 16 11:24:15 2010 @@ -643,6 +643,13 @@ DebugLoc DL = DebugLoc::getUnknownLoc(); if (I != MBB.end()) DL = I->getDebugLoc(); + // tGPR is used sometimes in ARM instructions that need to avoid using + // certain registers. Just treat it as GPR here. + if (DestRC == ARM::tGPRRegisterClass) + DestRC = ARM::GPRRegisterClass; + if (SrcRC == ARM::tGPRRegisterClass) + SrcRC = ARM::GPRRegisterClass; + if (DestRC != SrcRC) { if (DestRC->getSize() != SrcRC->getSize()) return false; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96360&r1=96359&r2=96360&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 11:24:15 2010 @@ -828,9 +828,10 @@ } // ARMv4T - def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops), + // Note: Restrict $func to the tGPR regclass to prevent it being in LR. + def BX : ABXIx2<(outs), (ins tGPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", - [(ARMcall_nolink GPR:$func)]>, + [(ARMcall_nolink tGPR:$func)]>, Requires<[IsARM, IsNotDarwin]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; @@ -865,9 +866,10 @@ } // ARMv4T - def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops), + // Note: Restrict $func to the tGPR regclass to prevent it being in LR. + def BXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", - [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> { + [(ARMcall_nolink tGPR:$func)]>, Requires<[IsARM, IsDarwin]> { let Inst{7-4} = 0b0001; let Inst{19-8} = 0b111111111111; let Inst{27-20} = 0b00010010; Modified: llvm/trunk/test/CodeGen/ARM/call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/call.ll?rev=96360&r1=96359&r2=96360&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/call.ll (original) +++ llvm/trunk/test/CodeGen/ARM/call.ll Tue Feb 16 11:24:15 2010 @@ -20,3 +20,17 @@ %tmp.upgrd.2 = tail call i32 %tmp( ) ; [#uses=0] ret void } + +define i32* @m_231b(i32, i32, i32*, i32*, i32*) nounwind { +; CHECKV4: m_231b +; CHECKV4: bx r{{.*}} +BB0: + %5 = inttoptr i32 %0 to i32* ; [#uses=1] + %t35 = volatile load i32* %5 ; [#uses=1] + %6 = inttoptr i32 %t35 to i32** ; [#uses=1] + %7 = getelementptr i32** %6, i32 86 ; [#uses=1] + %8 = load i32** %7 ; [#uses=1] + %9 = bitcast i32* %8 to i32* (i32, i32*, i32, i32*, i32*, i32*)* ; [#uses=1] + %10 = call i32* %9(i32 %0, i32* null, i32 %1, i32* %2, i32* %3, i32* %4) ; [#uses=1] + ret i32* %10 +} From sabre at nondot.org Tue Feb 16 13:03:57 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 19:03:57 -0000 Subject: [llvm-commits] [llvm] r96366 - /llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002161904.o1GJ42S9001869@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 13:03:34 2010 New Revision: 96366 URL: http://llvm.org/viewvc/llvm-project?rev=96366&view=rev Log: change dag isel emitter to only call 'IsProfitableToFold' on nodes with chains. On interior nodes that lead up to them, we just directly check that there is a single use. This generates slightly more efficient code. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96366&r1=96365&r2=96366&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 13:03:34 2010 @@ -568,9 +568,12 @@ // Check if it's profitable to fold the node. e.g. Check for multiple uses // of actual result? std::string ParentName(RootName.begin(), RootName.end()-1); - emitCheck("IsProfitableToFold(" + getValueName(RootName) + - ", " + getNodeName(ParentName) + ", N)"); - if (NodeHasChain) { + if (!NodeHasChain) { + // If this is just an interior node, check to see if it has a single + // use. If the node has multiple uses and the pattern has a load as + // an operand, then we can't fold the load. + emitCheck(getValueName(RootName) + ".hasOneUse()"); + } else { // If the immediate use can somehow reach this node through another // path, then can't fold it either or it will create a cycle. // e.g. In the following diagram, XX can reach ld through YY. If @@ -588,6 +591,8 @@ // We know we need the check if N's parent is not the root. bool NeedCheck = P != Pattern; if (!NeedCheck) { + // If the parent is the root and the node has more than one operand, + // we need to check. const SDNodeInfo &PInfo = CGP.getSDNodeInfo(P->getOperator()); NeedCheck = P->getOperator() == CGP.get_intrinsic_void_sdnode() || @@ -600,8 +605,13 @@ } if (NeedCheck) { + emitCheck("IsProfitableToFold(" + getValueName(RootName) + + ", " + getNodeName(ParentName) + ", N)"); emitCheck("IsLegalToFold(" + getValueName(RootName) + ", " + getNodeName(ParentName) + ", N)"); + } else { + // Otherwise, just verify that the node only has a single use. + emitCheck(getValueName(RootName) + ".hasOneUse()"); } } } From sabre at nondot.org Tue Feb 16 13:16:28 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 19:16:28 -0000 Subject: [llvm-commits] [llvm] r96368 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002161916.o1GJGW36002544@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 13:15:55 2010 New Revision: 96368 URL: http://llvm.org/viewvc/llvm-project?rev=96368&view=rev Log: convert the new matcher to check intermediate nodes for a single use and only call IsProfitableToFold/IsLegalToFold on the load being folded, like the old dagiselemitter does. This substantially simplifies the code and improves opportunities for sharing. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/utils/TableGen/DAGISelMatcher.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96368&r1=96367&r2=96368&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Tue Feb 16 13:15:55 2010 @@ -209,8 +209,7 @@ OPC_CheckComplexPat, OPC_CheckAndImm1, OPC_CheckAndImm2, OPC_CheckAndImm4, OPC_CheckAndImm8, OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8, - OPC_IsProfitableToFold, - OPC_IsLegalToFold + OPC_CheckFoldableChainNode }; struct MatchScope { @@ -382,19 +381,29 @@ if (CheckOrImmediate(N, GetInt8(MatcherTable, MatcherIndex))) break; continue; - case OPC_IsProfitableToFold: + case OPC_CheckFoldableChainNode: { assert(!NodeStack.size() == 1 && "No parent node"); + // Verify that all intermediate nodes between the root and this one have + // a single use. + bool HasMultipleUses = false; + for (unsigned i = 1, e = NodeStack.size()-1; i != e; ++i) + if (!NodeStack[i].hasOneUse()) { + HasMultipleUses = true; + break; + } + if (HasMultipleUses) break; + + // Check to see that the target thinks this is profitable to fold and that + // we can fold it without inducing cycles in the graph. if (!IsProfitableToFold(N, NodeStack[NodeStack.size()-2].getNode(), - NodeToMatch)) - break; - continue; - case OPC_IsLegalToFold: - assert(!NodeStack.size() == 1 && "No parent node"); - if (!IsLegalToFold(N, NodeStack[NodeStack.size()-2].getNode(), + NodeToMatch) || + !IsLegalToFold(N, NodeStack[NodeStack.size()-2].getNode(), NodeToMatch)) break; + continue; } + } // If the code reached this point, then the match failed pop out to the next // match scope. Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96368&r1=96367&r2=96368&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Tue Feb 16 13:15:55 2010 @@ -106,13 +106,8 @@ printChild(OS, indent); } -void CheckProfitableToFoldMatcherNode::print(raw_ostream &OS, - unsigned indent) const { - OS.indent(indent) << "CheckProfitableToFold\n"; - printChild(OS, indent); -} - -void CheckLegalToFoldMatcherNode::print(raw_ostream &OS, unsigned indent) const{ - OS.indent(indent) << "CheckLegalToFold\n"; +void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS, + unsigned indent) const { + OS.indent(indent) << "CheckFoldableChainNode\n"; printChild(OS, indent); } Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96368&r1=96367&r2=96368&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Tue Feb 16 13:15:55 2010 @@ -50,8 +50,7 @@ CheckComplexPat, CheckAndImm, CheckOrImm, - CheckProfitableToFold, - CheckLegalToFold + CheckFoldableChainNode }; const KindTy Kind; @@ -359,33 +358,20 @@ virtual void print(raw_ostream &OS, unsigned indent = 0) const; }; -/// CheckProfitableToFoldMatcherNode - This checks to see if the current node is -/// worthwhile to try to fold into a large pattern. -class CheckProfitableToFoldMatcherNode : public MatcherNodeWithChild { +/// CheckFoldableChainNodeMatcherNode - This checks to see if the current node +/// (which defines a chain operand) is safe to fold into a larger pattern. +class CheckFoldableChainNodeMatcherNode : public MatcherNodeWithChild { public: - CheckProfitableToFoldMatcherNode() - : MatcherNodeWithChild(CheckProfitableToFold) {} + CheckFoldableChainNodeMatcherNode() + : MatcherNodeWithChild(CheckFoldableChainNode) {} static inline bool classof(const MatcherNode *N) { - return N->getKind() == CheckProfitableToFold; + return N->getKind() == CheckFoldableChainNode; } virtual void print(raw_ostream &OS, unsigned indent = 0) const; }; -/// CheckLegalToFoldMatcherNode - This checks to see if the current node is -/// legal to try to fold into a large pattern. -class CheckLegalToFoldMatcherNode : public MatcherNodeWithChild { -public: - CheckLegalToFoldMatcherNode() - : MatcherNodeWithChild(CheckLegalToFold) {} - - static inline bool classof(const MatcherNode *N) { - return N->getKind() == CheckLegalToFold; - } - - virtual void print(raw_ostream &OS, unsigned indent = 0) const; -}; } // end namespace llvm #endif Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96368&r1=96367&r2=96368&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Tue Feb 16 13:15:55 2010 @@ -183,11 +183,8 @@ OS << "OPC_CheckOrImm" << ClassifyInt(Val) << ", "; return EmitInt(Val, OS)+1; } - case MatcherNode::CheckProfitableToFold: - OS << "OPC_IsProfitableToFold,\n"; - return 1; - case MatcherNode::CheckLegalToFold: - OS << "OPC_IsLegalToFold,\n"; + case MatcherNode::CheckFoldableChainNode: + OS << "OPC_CheckFoldableChainNode,\n"; return 1; } assert(0 && "Unreachable"); Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96368&r1=96367&r2=96368&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 13:15:55 2010 @@ -212,9 +212,7 @@ const TreePatternNode *Root = Pattern.getSrcPattern(); if (N != Root && // Not the root of the pattern. N->TreeHasProperty(SDNPHasChain, CGP)) { // Has a chain somewhere in tree. - - AddMatcherNode(new CheckProfitableToFoldMatcherNode()); - + // If this non-root node produces a chain, we may need to emit a validity // check. if (OpNo != 0) { @@ -239,7 +237,7 @@ } if (NeedCheck) - AddMatcherNode(new CheckLegalToFoldMatcherNode()); + AddMatcherNode(new CheckFoldableChainNodeMatcherNode()); } } From sabre at nondot.org Tue Feb 16 13:20:02 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 19:20:02 -0000 Subject: [llvm-commits] [llvm] r96369 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002161920.o1GJK29j002763@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 13:19:58 2010 New Revision: 96369 URL: http://llvm.org/viewvc/llvm-project?rev=96369&view=rev Log: simplify this code. In the new world order there is no need to scan the entire subtree of the pattern anymore. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96369&r1=96368&r2=96369&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 13:19:58 2010 @@ -186,36 +186,33 @@ // If this node has a chain, then the chain is operand #0 is the SDNode, and // the child numbers of the node are all offset by one. unsigned OpNo = 0; - if (N->NodeHasProperty(SDNPHasChain, CGP)) + if (N->NodeHasProperty(SDNPHasChain, CGP)) { OpNo = 1; - // If this node is not the root and the subtree underneath it produces a - // chain, then the result of matching the node is also produce a chain. - // Beyond that, this means that we're also folding (at least) the root node - // into the node that produce the chain (for example, matching - // "(add reg, (load ptr))" as a add_with_memory on X86). This is problematic, - // if the 'reg' node also uses the load (say, its chain). Graphically: - // - // [LD] - // ^ ^ - // | \ DAG's like cheese. - // / | - // / [YY] - // | ^ - // [XX]--/ - // - // It would be invalid to fold XX and LD. In this case, folding the two - // nodes together would induce a cycle in the DAG, making it a cyclic DAG (!). - // To prevent this, we emit a dynamic check for legality before allowing this - // to be folded. - // - const TreePatternNode *Root = Pattern.getSrcPattern(); - if (N != Root && // Not the root of the pattern. - N->TreeHasProperty(SDNPHasChain, CGP)) { // Has a chain somewhere in tree. - - // If this non-root node produces a chain, we may need to emit a validity - // check. - if (OpNo != 0) { + // If this node is not the root and the subtree underneath it produces a + // chain, then the result of matching the node is also produce a chain. + // Beyond that, this means that we're also folding (at least) the root node + // into the node that produce the chain (for example, matching + // "(add reg, (load ptr))" as a add_with_memory on X86). This is + // problematic, if the 'reg' node also uses the load (say, its chain). + // Graphically: + // + // [LD] + // ^ ^ + // | \ DAG's like cheese. + // / | + // / [YY] + // | ^ + // [XX]--/ + // + // It would be invalid to fold XX and LD. In this case, folding the two + // nodes together would induce a cycle in the DAG, making it a 'cyclic DAG' + // To prevent this, we emit a dynamic check for legality before allowing + // this to be folded. + // + const TreePatternNode *Root = Pattern.getSrcPattern(); + if (N != Root) { // Not the root of the pattern. + // If there is a node between the root and this node, then we definitely // need to emit the check. bool NeedCheck = !Root->hasChild(N); From kennethuil at gmail.com Tue Feb 16 13:28:15 2010 From: kennethuil at gmail.com (Kenneth Uildriks) Date: Tue, 16 Feb 2010 19:28:15 -0000 Subject: [llvm-commits] [llvm] r96370 - /llvm/trunk/lib/VMCore/Core.cpp Message-ID: <201002161928.o1GJSHHD003225@zion.cs.uiuc.edu> Author: kennethuil Date: Tue Feb 16 13:28:02 2010 New Revision: 96370 URL: http://llvm.org/viewvc/llvm-project?rev=96370&view=rev Log: Function attributes have index ~0, not 0 Modified: llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=96370&r1=96369&r2=96370&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Tue Feb 16 13:28:02 2010 @@ -1215,14 +1215,14 @@ void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { Function *Func = unwrap(Fn); const AttrListPtr PAL = Func->getAttributes(); - const AttrListPtr PALnew = PAL.addAttr(0, PA); + const AttrListPtr PALnew = PAL.addAttr(~0U, PA); Func->setAttributes(PALnew); } void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) { Function *Func = unwrap(Fn); const AttrListPtr PAL = Func->getAttributes(); - const AttrListPtr PALnew = PAL.removeAttr(0, PA); + const AttrListPtr PALnew = PAL.removeAttr(~0U, PA); Func->setAttributes(PALnew); } From gohman at apple.com Tue Feb 16 13:42:47 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Feb 2010 19:42:47 -0000 Subject: [llvm-commits] [llvm] r96372 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <201002161942.o1GJgppE004044@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 13:42:34 2010 New Revision: 96372 URL: http://llvm.org/viewvc/llvm-project?rev=96372&view=rev Log: Fix whitespace. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96372&r1=96371&r2=96372&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Feb 16 13:42:34 2010 @@ -640,9 +640,9 @@ /// RatePrimaryRegister - Record this register in the set. If we haven't seen it /// before, rate it. void Cost::RatePrimaryRegister(const SCEV *Reg, - SmallPtrSet &Regs, - const Loop *L, - ScalarEvolution &SE, DominatorTree &DT) { + SmallPtrSet &Regs, + const Loop *L, + ScalarEvolution &SE, DominatorTree &DT) { if (Regs.insert(Reg)) RateRegister(Reg, Regs, L, SE, DT); } From bob.wilson at apple.com Tue Feb 16 13:49:23 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Feb 2010 19:49:23 -0000 Subject: [llvm-commits] [llvm] r96377 - in /llvm/trunk: include/llvm/Transforms/Utils/BasicBlockUtils.h lib/Transforms/Scalar/GVN.cpp lib/Transforms/Utils/BasicBlockUtils.cpp Message-ID: <201002161949.o1GJnc0d004362@zion.cs.uiuc.edu> Author: bwilson Date: Tue Feb 16 13:49:17 2010 New Revision: 96377 URL: http://llvm.org/viewvc/llvm-project?rev=96377&view=rev Log: Refactor to share code to find the position of a basic block successor in the terminator's list of successors. Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=96377&r1=96376&r2=96377&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Tue Feb 16 13:49:17 2010 @@ -102,6 +102,11 @@ // void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum); +/// SuccessorNumber - Search for the specified successor of basic block BB and +/// return its position in the terminator instruction's list of successors. +/// It is an error to call this with a block that is not a successor. +unsigned SuccessorNumber(BasicBlock *BB, BasicBlock *Succ); + /// isCriticalEdge - Return true if the specified edge is a critical edge. /// Critical edges are edges from a block with multiple successors to a block /// with multiple predecessors. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=96377&r1=96376&r2=96377&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Feb 16 13:49:17 2010 @@ -2141,14 +2141,7 @@ // We can't do PRE safely on a critical edge, so instead we schedule // the edge to be split and perform the PRE the next time we iterate // on the function. - unsigned SuccNum = 0; - for (unsigned i = 0, e = PREPred->getTerminator()->getNumSuccessors(); - i != e; ++i) - if (PREPred->getTerminator()->getSuccessor(i) == CurrentBlock) { - SuccNum = i; - break; - } - + unsigned SuccNum = SuccessorNumber(PREPred, CurrentBlock); if (isCriticalEdge(PREPred->getTerminator(), SuccNum)) { toSplit.push_back(std::make_pair(PREPred->getTerminator(), SuccNum)); continue; Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=96377&r1=96376&r2=96377&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Tue Feb 16 13:49:17 2010 @@ -274,24 +274,30 @@ ReplaceInstWithInst(TI, NewTI); } -/// SplitEdge - Split the edge connecting specified block. Pass P must -/// not be NULL. -BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) { - TerminatorInst *LatchTerm = BB->getTerminator(); - unsigned SuccNum = 0; +/// SuccessorNumber - Search for the specified successor of basic block BB and +/// return its position in the terminator instruction's list of successors. +/// It is an error to call this with a block that is not a successor. +unsigned llvm::SuccessorNumber(BasicBlock *BB, BasicBlock *Succ) { + TerminatorInst *Term = BB->getTerminator(); #ifndef NDEBUG - unsigned e = LatchTerm->getNumSuccessors(); + unsigned e = Term->getNumSuccessors(); #endif for (unsigned i = 0; ; ++i) { assert(i != e && "Didn't find edge?"); - if (LatchTerm->getSuccessor(i) == Succ) { - SuccNum = i; - break; - } + if (Term->getSuccessor(i) == Succ) + return i; } + return 0; +} + +/// SplitEdge - Split the edge connecting specified block. Pass P must +/// not be NULL. +BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) { + unsigned SuccNum = SuccessorNumber(BB, Succ); // If this is a critical edge, let SplitCriticalEdge do it. - if (SplitCriticalEdge(BB->getTerminator(), SuccNum, P)) + TerminatorInst *LatchTerm = BB->getTerminator(); + if (SplitCriticalEdge(LatchTerm, SuccNum, P)) return LatchTerm->getSuccessor(SuccNum); // If the edge isn't critical, then BB has a single successor or Succ has a From bob.wilson at apple.com Tue Feb 16 13:52:06 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Feb 2010 19:52:06 -0000 Subject: [llvm-commits] [llvm] r96378 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/GVN.cpp Message-ID: <201002161952.o1GJqCQt004473@zion.cs.uiuc.edu> Author: bwilson Date: Tue Feb 16 13:51:59 2010 New Revision: 96378 URL: http://llvm.org/viewvc/llvm-project?rev=96378&view=rev Log: Split critical edges as needed for load PRE. Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=96378&r1=96377&r2=96378&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Tue Feb 16 13:51:59 2010 @@ -249,7 +249,7 @@ SmallPtrSet > ReverseDepMapType; ReverseDepMapType ReverseLocalDeps; - // A reverse mapping form dependencies to the non-local dependees. + // A reverse mapping from dependencies to the non-local dependees. ReverseDepMapType ReverseNonLocalDeps; /// Current AA implementation, just a cache. @@ -312,6 +312,11 @@ /// value and replaces the other value with ptr. This can make Ptr available /// in more places that cached info does not necessarily keep. void invalidateCachedPointerInfo(Value *Ptr); + + /// invalidateCachedPredecessors - Clear the PredIteratorCache info. + /// This needs to be done when the CFG changes, e.g., due to splitting + /// critical edges. + void invalidateCachedPredecessors(); private: MemDepResult getPointerDependencyFrom(Value *Pointer, uint64_t MemSize, Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=96378&r1=96377&r2=96378&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Feb 16 13:51:59 2010 @@ -1016,6 +1016,13 @@ RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(Ptr, true)); } +/// invalidateCachedPredecessors - Clear the PredIteratorCache info. +/// This needs to be done when the CFG changes, e.g., due to splitting +/// critical edges. +void MemoryDependenceAnalysis::invalidateCachedPredecessors() { + PredCache->clear(); +} + /// removeInstruction - Remove an instruction from the dependence analysis, /// updating the dependence of instructions that previously depended on it. /// This method attempts to keep the cache coherent using the reverse map. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=96378&r1=96377&r2=96378&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Feb 16 13:51:59 2010 @@ -674,6 +674,9 @@ ValueTable VN; DenseMap localAvail; + // List of critical edges to be split between iterations. + SmallVector, 4> toSplit; + // This transformation requires dominator postdominator info virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); @@ -701,6 +704,7 @@ Value *lookupNumber(BasicBlock *BB, uint32_t num); void cleanupGlobalSets(); void verifyRemoved(const Instruction *I) const; + bool splitCriticalEdges(); }; char GVN::ID = 0; @@ -1583,10 +1587,15 @@ continue; } PredLoads[Pred] = 0; - // We don't currently handle critical edges :( + if (Pred->getTerminator()->getNumSuccessors() != 1) { - DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF CRITICAL EDGE '" - << Pred->getName() << "': " << *LI << '\n'); + if (isa(Pred->getTerminator())) { + DEBUG(dbgs() << "COULD NOT PRE LOAD BECAUSE OF INDBR CRITICAL EDGE '" + << Pred->getName() << "': " << *LI << '\n'); + return false; + } + unsigned SuccNum = SuccessorNumber(Pred, LoadBB); + toSplit.push_back(std::make_pair(Pred->getTerminator(), SuccNum)); return false; } } @@ -2004,6 +2013,8 @@ while (ShouldContinue) { DEBUG(dbgs() << "GVN iteration: " << Iteration << "\n"); ShouldContinue = iterateOnFunction(F); + if (splitCriticalEdges()) + ShouldContinue = true; Changed |= ShouldContinue; ++Iteration; } @@ -2070,7 +2081,6 @@ /// control flow patterns and attempts to perform simple PRE at the join point. bool GVN::performPRE(Function &F) { bool Changed = false; - SmallVector, 4> toSplit; DenseMap predMap; for (df_iterator DI = df_begin(&F.getEntryBlock()), DE = df_end(&F.getEntryBlock()); DI != DE; ++DI) { @@ -2209,11 +2219,23 @@ } } - for (SmallVector, 4>::iterator - I = toSplit.begin(), E = toSplit.end(); I != E; ++I) - SplitCriticalEdge(I->first, I->second, this); + if (splitCriticalEdges()) + Changed = true; + + return Changed; +} - return Changed || toSplit.size(); +/// splitCriticalEdges - Split critical edges found during the previous +/// iteration that may enable further optimization. +bool GVN::splitCriticalEdges() { + if (toSplit.empty()) + return false; + do { + std::pair Edge = toSplit.pop_back_val(); + SplitCriticalEdge(Edge.first, Edge.second, this); + } while (!toSplit.empty()); + MD->invalidateCachedPredecessors(); + return true; } /// iterateOnFunction - Executes one iteration of GVN From johnny.chen at apple.com Tue Feb 16 14:05:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Feb 2010 20:05:04 -0000 Subject: [llvm-commits] [llvm] r96380 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002162005.o1GK564x005259@zion.cs.uiuc.edu> Author: johnny Date: Tue Feb 16 14:04:27 2010 New Revision: 96380 URL: http://llvm.org/viewvc/llvm-project?rev=96380&view=rev Log: Added for disassembly the following instructions: o Store Return State (SRSW, SRS) o Load/Store Coprocessor (LDC/STC and friends) o MSR (immediate) Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96380&r1=96379&r2=96380&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 14:04:27 2010 @@ -933,12 +933,27 @@ let Inst{7-4} = 0b0010; } -// Supervisor call (software interrupt) -- for disassembly only +// Supervisor Call (Software Interrupt) -- for disassembly only let isCall = 1 in { def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc", [/* For disassembly only; pattern left blank */]>; } +// Store Return State -- for disassembly only +def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$opt), + NoItinerary, "srs${addr:submode}\tsp!, $opt", + [/* For disassembly only; pattern left blank */]> { + let Inst{31-28} = 0b1111; + let Inst{22-20} = 0b110; // W = 1 +} + +def SRS : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode), + NoItinerary, "srs${addr:submode}\tsp, $mode", + [/* For disassembly only; pattern left blank */]> { + let Inst{31-28} = 0b1111; + let Inst{22-20} = 0b100; // W = 0 +} + //===----------------------------------------------------------------------===// // Load / store Instructions. // @@ -2203,6 +2218,102 @@ let Inst{4} = 0; } +class ACI + : I { + let Inst{27-25} = 0b110; +} + +multiclass LdStCop op31_28, bit load, string opc> { + + def _OFFSET : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), + opc, "\tp$cop, cr$CRd, $addr"> { + let Inst{31-28} = op31_28; + let Inst{24} = 1; // P = 1 + let Inst{21} = 0; // W = 0 + let Inst{22} = 0; // D = 0 + let Inst{20} = load; + } + + def _PRE : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), + opc, "\tp$cop, cr$CRd, $addr!"> { + let Inst{31-28} = op31_28; + let Inst{24} = 1; // P = 1 + let Inst{21} = 1; // W = 1 + let Inst{22} = 0; // D = 0 + let Inst{20} = load; + } + + def _POST : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset), + opc, "\tp$cop, cr$CRd, [$base], $offset"> { + let Inst{31-28} = op31_28; + let Inst{24} = 0; // P = 0 + let Inst{21} = 1; // W = 1 + let Inst{22} = 0; // D = 0 + let Inst{20} = load; + } + + def _OPTION : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option), + opc, "\tp$cop, cr$CRd, [$base], $option"> { + let Inst{31-28} = op31_28; + let Inst{24} = 0; // P = 0 + let Inst{23} = 1; // U = 1 + let Inst{21} = 0; // W = 0 + let Inst{22} = 0; // D = 0 + let Inst{20} = load; + } + + def L_OFFSET : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), + opc, "l\tp$cop, cr$CRd, $addr"> { + let Inst{31-28} = op31_28; + let Inst{24} = 1; // P = 1 + let Inst{21} = 0; // W = 0 + let Inst{22} = 1; // D = 1 + let Inst{20} = load; + } + + def L_PRE : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), + opc, "l\tp$cop, cr$CRd, $addr!"> { + let Inst{31-28} = op31_28; + let Inst{24} = 1; // P = 1 + let Inst{21} = 1; // W = 1 + let Inst{22} = 1; // D = 1 + let Inst{20} = load; + } + + def L_POST : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset), + opc, "l\tp$cop, cr$CRd, [$base], $offset"> { + let Inst{31-28} = op31_28; + let Inst{24} = 0; // P = 0 + let Inst{21} = 1; // W = 1 + let Inst{22} = 1; // D = 1 + let Inst{20} = load; + } + + def L_OPTION : ACI<(outs), + (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option), + opc, "l\tp$cop, cr$CRd, [$base], $option"> { + let Inst{31-28} = op31_28; + let Inst{24} = 0; // P = 0 + let Inst{23} = 1; // U = 1 + let Inst{21} = 0; // W = 0 + let Inst{22} = 1; // D = 1 + let Inst{20} = load; + } +} + +defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">; +defm LDC2 : LdStCop<0b1111, 1, "ldc2">; +defm STC : LdStCop<{?,?,?,?}, 0, "stc">; +defm STC2 : LdStCop<0b1111, 0, "stc2">; + def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1, GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2), NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2", @@ -2284,14 +2395,28 @@ } // FIXME: mask is ignored for the time being. -def MSR : ABI<0b0001,(outs),(ins GPR:$src), NoItinerary, "mrs", "\tcpsr, $src", +def MSR : ABI<0b0001,(outs),(ins GPR:$src), NoItinerary, "msr", "\tcpsr, $src", [/* For disassembly only; pattern left blank */]> { let Inst{23-20} = 0b0010; let Inst{7-4} = 0b0000; } // FIXME: mask is ignored for the time being. -def MSRsys : ABI<0b0001,(outs),(ins GPR:$src),NoItinerary,"mrs","\tspsr, $src", +def MSRi : ABI<0b0011,(outs),(ins so_imm:$a), NoItinerary, "msr", "\tcpsr, $a", + [/* For disassembly only; pattern left blank */]> { + let Inst{23-20} = 0b0010; + let Inst{7-4} = 0b0000; +} + +// FIXME: mask is ignored for the time being. +def MSRsys : ABI<0b0001,(outs),(ins GPR:$src),NoItinerary,"msr","\tspsr, $src", + [/* For disassembly only; pattern left blank */]> { + let Inst{23-20} = 0b0110; + let Inst{7-4} = 0b0000; +} + +// FIXME: mask is ignored for the time being. +def MSRsysi : ABI<0b0011,(outs),(ins so_imm:$a),NoItinerary,"msr","\tspsr, $a", [/* For disassembly only; pattern left blank */]> { let Inst{23-20} = 0b0110; let Inst{7-4} = 0b0000; From grosbach at apple.com Tue Feb 16 14:18:14 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 16 Feb 2010 20:18:14 -0000 Subject: [llvm-commits] [llvm] r96381 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002162018.o1GKIIFk005856@zion.cs.uiuc.edu> Author: grosbach Date: Tue Feb 16 14:17:57 2010 New Revision: 96381 URL: http://llvm.org/viewvc/llvm-project?rev=96381&view=rev Log: First step in eliminating the CarryDefIsUnused and CarryDefIsUsed predicates. They won't work with the new ISel mechanism, as Requires predicates are no longer allowed to reference the node being selected. Moving the predicate to the patterns instead solves the problem. This patch handles ARM mode. Thumb2 will follow. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96381&r1=96380&r2=96381&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 14:17:57 2010 @@ -236,6 +236,21 @@ class BinOpFrag : PatFrag<(ops node:$LHS, node:$RHS), res>; class UnOpFrag : PatFrag<(ops node:$Src), res>; +/// adde and sube predicates - True based on whether the carry flag output +/// will be needed or not. +def adde_dead_carry : + PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS), + [{return !N->hasAnyUseOfValue(1);}]>; +def sube_dead_carry : + PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS), + [{return !N->hasAnyUseOfValue(1);}]>; +def adde_live_carry : + PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS), + [{return N->hasAnyUseOfValue(1);}]>; +def sube_live_carry : + PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS), + [{return N->hasAnyUseOfValue(1);}]>; + //===----------------------------------------------------------------------===// // Operand Definitions. // @@ -524,13 +539,13 @@ def ri : AsI1, - Requires<[IsARM, CarryDefIsUnused]> { + Requires<[IsARM]> { let Inst{25} = 1; } def rr : AsI1, - Requires<[IsARM, CarryDefIsUnused]> { + Requires<[IsARM]> { let isCommutable = Commutable; let Inst{11-4} = 0b00000000; let Inst{25} = 0; @@ -538,7 +553,7 @@ def rs : AsI1, - Requires<[IsARM, CarryDefIsUnused]> { + Requires<[IsARM]> { let Inst{25} = 0; } } @@ -549,7 +564,7 @@ def Sri : AXI1, - Requires<[IsARM, CarryDefIsUsed]> { + Requires<[IsARM]> { let Defs = [CPSR]; let Inst{20} = 1; let Inst{25} = 1; @@ -557,7 +572,7 @@ def Srr : AXI1, - Requires<[IsARM, CarryDefIsUsed]> { + Requires<[IsARM]> { let Defs = [CPSR]; let Inst{11-4} = 0b00000000; let Inst{20} = 1; @@ -566,7 +581,7 @@ def Srs : AXI1, - Requires<[IsARM, CarryDefIsUsed]> { + Requires<[IsARM]> { let Defs = [CPSR]; let Inst{20} = 1; let Inst{25} = 0; @@ -1290,13 +1305,13 @@ BinOpFrag<(subc node:$LHS, node:$RHS)>>; defm ADC : AI1_adde_sube_irs<0b0101, "adc", - BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>; + BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>; defm SBC : AI1_adde_sube_irs<0b0110, "sbc", - BinOpFrag<(sube node:$LHS, node:$RHS)>>; + BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>; defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs", - BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>; + BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>; defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs", - BinOpFrag<(sube node:$LHS, node:$RHS)>>; + BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>; // These don't define reg/reg forms, because they are handled above. def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm, @@ -1330,14 +1345,14 @@ let Uses = [CPSR] in { def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iALUi, "rsc", "\t$dst, $a, $b", - [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>, - Requires<[IsARM, CarryDefIsUnused]> { + [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>, + Requires<[IsARM]> { let Inst{25} = 1; } def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b", - [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>, - Requires<[IsARM, CarryDefIsUnused]> { + [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>, + Requires<[IsARM]> { let Inst{25} = 0; } } @@ -1346,15 +1361,15 @@ let Defs = [CPSR], Uses = [CPSR] in { def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iALUi, "rscs\t$dst, $a, $b", - [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>, - Requires<[IsARM, CarryDefIsUnused]> { + [(set GPR:$dst, (sube_dead_carry so_imm:$b, GPR:$a))]>, + Requires<[IsARM]> { let Inst{20} = 1; let Inst{25} = 1; } def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b", - [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>, - Requires<[IsARM, CarryDefIsUnused]> { + [(set GPR:$dst, (sube_dead_carry so_reg:$b, GPR:$a))]>, + Requires<[IsARM]> { let Inst{20} = 1; let Inst{25} = 0; } From gohman at apple.com Tue Feb 16 14:22:26 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Feb 2010 12:22:26 -0800 Subject: [llvm-commits] [llvm] r95975 - in /llvm/trunk: include/llvm/Analysis/ lib/Analysis/ lib/CodeGen/ lib/Transforms/Scalar/ test/CodeGen/ARM/ test/CodeGen/Thumb2/ test/CodeGen/X86/ test/Transforms/IndVarSimplify/ test/Transforms/LoopStrengthReduce/ In-Reply-To: <352a1fb21002152349v3b61242cnbb1a99f97fa018c4@mail.gmail.com> References: <201002121034.o1CAYXSw030410@zion.cs.uiuc.edu> <352a1fb21002152349v3b61242cnbb1a99f97fa018c4@mail.gmail.com> Message-ID: On Feb 15, 2010, at 11:49 PM, Devang Patel wrote: >> + if (SE.isSCEVable(PN->getType()) && >> + (SE.getEffectiveSCEVType(PN->getType()) == >> + SE.getEffectiveSCEVType(AR->getType())) && >> + SE.getSCEV(PN) == AR) >> + goto no_cost; >> + > > goto! Yep! Dan From gohman at apple.com Tue Feb 16 14:25:20 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Feb 2010 20:25:20 -0000 Subject: [llvm-commits] [llvm] r96382 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <201002162025.o1GKPLtl006205@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 14:25:07 2010 New Revision: 96382 URL: http://llvm.org/viewvc/llvm-project?rev=96382&view=rev Log: Refactor rewriting for PHI nodes into a separate function. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96382&r1=96381&r2=96382&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Feb 16 14:25:07 2010 @@ -1188,6 +1188,13 @@ SCEVExpander &Rewriter, SmallVectorImpl &DeadInsts, ScalarEvolution &SE, DominatorTree &DT) const; + void RewriteForPHI(PHINode *PN, const LSRFixup &LF, + const Formula &F, + Loop *L, Instruction *IVIncInsertPos, + SCEVExpander &Rewriter, + SmallVectorImpl &DeadInsts, + ScalarEvolution &SE, DominatorTree &DT, + Pass *P) const; void Rewrite(const LSRFixup &LF, const Formula &F, Loop *L, Instruction *IVIncInsertPos, @@ -2921,6 +2928,67 @@ return FullV; } +/// RewriteForPHI - Helper for Rewrite. PHI nodes are special because the use +/// of their operands effectively happens in their predecessor blocks, so the +/// expression may need to be expanded in multiple places. +void LSRInstance::RewriteForPHI(PHINode *PN, + const LSRFixup &LF, + const Formula &F, + Loop *L, Instruction *IVIncInsertPos, + SCEVExpander &Rewriter, + SmallVectorImpl &DeadInsts, + ScalarEvolution &SE, DominatorTree &DT, + Pass *P) const { + DenseMap Inserted; + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + if (PN->getIncomingValue(i) == LF.OperandValToReplace) { + BasicBlock *BB = PN->getIncomingBlock(i); + + // If this is a critical edge, split the edge so that we do not insert + // the code on all predecessor/successor paths. We do this unless this + // is the canonical backedge for this loop, which complicates post-inc + // users. + if (e != 1 && BB->getTerminator()->getNumSuccessors() > 1 && + !isa(BB->getTerminator()) && + (PN->getParent() != L->getHeader() || !L->contains(BB))) { + // Split the critical edge. + BasicBlock *NewBB = SplitCriticalEdge(BB, PN->getParent(), P); + + // If PN is outside of the loop and BB is in the loop, we want to + // move the block to be immediately before the PHI block, not + // immediately after BB. + if (L->contains(BB) && !L->contains(PN)) + NewBB->moveBefore(PN->getParent()); + + // Splitting the edge can reduce the number of PHI entries we have. + e = PN->getNumIncomingValues(); + BB = NewBB; + i = PN->getBasicBlockIndex(BB); + } + + std::pair::iterator, bool> Pair = + Inserted.insert(std::make_pair(BB, static_cast(0))); + if (!Pair.second) + PN->setIncomingValue(i, Pair.first->second); + else { + Value *FullV = Expand(LF, F, BB->getTerminator(), L, IVIncInsertPos, + Rewriter, DeadInsts, SE, DT); + + // If this is reuse-by-noop-cast, insert the noop cast. + const Type *OpTy = LF.OperandValToReplace->getType(); + if (FullV->getType() != OpTy) + FullV = + CastInst::Create(CastInst::getCastOpcode(FullV, false, + OpTy, false), + FullV, LF.OperandValToReplace->getType(), + "tmp", BB->getTerminator()); + + PN->setIncomingValue(i, FullV); + Pair.first->second = FullV; + } + } +} + /// Rewrite - Emit instructions for the leading candidate expression for this /// LSRUse (this is called "expanding"), and update the UserInst to reference /// the newly expanded value. @@ -2931,63 +2999,16 @@ SmallVectorImpl &DeadInsts, ScalarEvolution &SE, DominatorTree &DT, Pass *P) const { - const Type *OpTy = LF.OperandValToReplace->getType(); - // First, find an insertion point that dominates UserInst. For PHI nodes, // find the nearest block which dominates all the relevant uses. if (PHINode *PN = dyn_cast(LF.UserInst)) { - DenseMap Inserted; - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - if (PN->getIncomingValue(i) == LF.OperandValToReplace) { - BasicBlock *BB = PN->getIncomingBlock(i); - - // If this is a critical edge, split the edge so that we do not insert - // the code on all predecessor/successor paths. We do this unless this - // is the canonical backedge for this loop, which complicates post-inc - // users. - if (e != 1 && BB->getTerminator()->getNumSuccessors() > 1 && - !isa(BB->getTerminator()) && - (PN->getParent() != L->getHeader() || !L->contains(BB))) { - // Split the critical edge. - BasicBlock *NewBB = SplitCriticalEdge(BB, PN->getParent(), P); - - // If PN is outside of the loop and BB is in the loop, we want to - // move the block to be immediately before the PHI block, not - // immediately after BB. - if (L->contains(BB) && !L->contains(PN)) - NewBB->moveBefore(PN->getParent()); - - // Splitting the edge can reduce the number of PHI entries we have. - e = PN->getNumIncomingValues(); - BB = NewBB; - i = PN->getBasicBlockIndex(BB); - } - - std::pair::iterator, bool> Pair = - Inserted.insert(std::make_pair(BB, static_cast(0))); - if (!Pair.second) - PN->setIncomingValue(i, Pair.first->second); - else { - Value *FullV = Expand(LF, F, BB->getTerminator(), L, IVIncInsertPos, - Rewriter, DeadInsts, SE, DT); - - // If this is reuse-by-noop-cast, insert the noop cast. - if (FullV->getType() != OpTy) - FullV = - CastInst::Create(CastInst::getCastOpcode(FullV, false, - OpTy, false), - FullV, LF.OperandValToReplace->getType(), - "tmp", BB->getTerminator()); - - PN->setIncomingValue(i, FullV); - Pair.first->second = FullV; - } - } + RewriteForPHI(PN, LF, F, L, IVIncInsertPos, Rewriter, DeadInsts, SE, DT, P); } else { Value *FullV = Expand(LF, F, LF.UserInst, L, IVIncInsertPos, Rewriter, DeadInsts, SE, DT); // If this is reuse-by-noop-cast, insert the noop cast. + const Type *OpTy = LF.OperandValToReplace->getType(); if (FullV->getType() != OpTy) { Instruction *Cast = CastInst::Create(CastInst::getCastOpcode(FullV, false, OpTy, false), From grosbach at apple.com Tue Feb 16 14:36:27 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 16 Feb 2010 20:36:27 -0000 Subject: [llvm-commits] [llvm] r96383 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002162036.o1GKaYSE006842@zion.cs.uiuc.edu> Author: grosbach Date: Tue Feb 16 14:35:59 2010 New Revision: 96383 URL: http://llvm.org/viewvc/llvm-project?rev=96383&view=rev Log: Remove redundant setting of Defs. CPSR is already marked by the block level set of Defs. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96383&r1=96382&r2=96383&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 14:35:59 2010 @@ -565,7 +565,6 @@ DPFrm, IIC_iALUi, !strconcat(opc, "\t$dst, $a, $b"), [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>, Requires<[IsARM]> { - let Defs = [CPSR]; let Inst{20} = 1; let Inst{25} = 1; } @@ -573,7 +572,6 @@ DPFrm, IIC_iALUr, !strconcat(opc, "\t$dst, $a, $b"), [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, Requires<[IsARM]> { - let Defs = [CPSR]; let Inst{11-4} = 0b00000000; let Inst{20} = 1; let Inst{25} = 0; @@ -582,7 +580,6 @@ DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$dst, $a, $b"), [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>, Requires<[IsARM]> { - let Defs = [CPSR]; let Inst{20} = 1; let Inst{25} = 0; } From grosbach at apple.com Tue Feb 16 14:42:55 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 16 Feb 2010 20:42:55 -0000 Subject: [llvm-commits] [llvm] r96384 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb2.td Message-ID: <201002162042.o1GKgw0I007196@zion.cs.uiuc.edu> Author: grosbach Date: Tue Feb 16 14:42:29 2010 New Revision: 96384 URL: http://llvm.org/viewvc/llvm-project?rev=96384&view=rev Log: Update Thumb2 to not use CarryDefIsUnused or CarryDefIsUsed predicates, but to have the predicate on the pattern itself instead. Support for the new ISel. Remove definitions of CarryDefIsUnused and CarryDefIsUsed since they are no longer used anywhere. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96384&r1=96383&r2=96384&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 14:42:29 2010 @@ -130,8 +130,6 @@ def IsARM : Predicate<"!Subtarget->isThumb()">; def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">; def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">; -def CarryDefIsUnused : Predicate<"!N->hasAnyUseOfValue(1)">; -def CarryDefIsUsed : Predicate<"N->hasAnyUseOfValue(1)">; // FIXME: Eventually this will be just "hasV6T2Ops". def UseMovt : Predicate<"Subtarget->useMovt()">; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=96384&r1=96383&r2=96384&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Feb 16 14:42:29 2010 @@ -368,7 +368,7 @@ } /// T2I_adde_sube_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns -/// for a binary operation that produces a value and use and define the carry +/// for a binary operation that produces a value and use the carry /// bit. It's not predicable. let Uses = [CPSR] in { multiclass T2I_adde_sube_irs opcod, string opc, PatFrag opnode, bit Commutable = 0> { @@ -376,7 +376,7 @@ def ri : T2sI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi, opc, "\t$dst, $lhs, $rhs", [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>, - Requires<[IsThumb2, CarryDefIsUnused]> { + Requires<[IsThumb2]> { let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = opcod; @@ -387,7 +387,7 @@ def rr : T2sI<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), IIC_iALUr, opc, ".w\t$dst, $lhs, $rhs", [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))]>, - Requires<[IsThumb2, CarryDefIsUnused]> { + Requires<[IsThumb2]> { let isCommutable = Commutable; let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; @@ -401,19 +401,22 @@ def rs : T2sI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi, opc, ".w\t$dst, $lhs, $rhs", [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>, - Requires<[IsThumb2, CarryDefIsUnused]> { + Requires<[IsThumb2]> { let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; let Inst{20} = 0; // The S bit. } - // Carry setting variants +} + +// Carry setting variants +let Defs = [CPSR] in { +multiclass T2I_adde_sube_s_irs opcod, string opc, PatFrag opnode, bit Commutable = 0> { // shifted imm - def Sri : T2XI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi, - !strconcat(opc, "s\t$dst, $lhs, $rhs"), + def Sri : T2sI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi, + opc, "\t$dst, $lhs, $rhs", [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>, - Requires<[IsThumb2, CarryDefIsUsed]> { - let Defs = [CPSR]; + Requires<[IsThumb2]> { let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24-21} = opcod; @@ -421,11 +424,10 @@ let Inst{15} = 0; } // register - def Srr : T2XI<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), IIC_iALUr, - !strconcat(opc, "s.w\t$dst, $lhs, $rhs"), + def Srr : T2sI<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), IIC_iALUr, + opc, ".w\t$dst, $lhs, $rhs", [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))]>, - Requires<[IsThumb2, CarryDefIsUsed]> { - let Defs = [CPSR]; + Requires<[IsThumb2]> { let isCommutable = Commutable; let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; @@ -436,11 +438,10 @@ let Inst{5-4} = 0b00; // type } // shifted register - def Srs : T2XI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi, - !strconcat(opc, "s.w\t$dst, $lhs, $rhs"), + def Srs : T2sI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), IIC_iALUsi, + opc, ".w\t$dst, $lhs, $rhs", [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>, - Requires<[IsThumb2, CarryDefIsUsed]> { - let Defs = [CPSR]; + Requires<[IsThumb2]> { let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; @@ -448,6 +449,7 @@ } } } +} /// T2I_rbin_s_is - Same as T2I_rbin_is except sets 's' bit. let Defs = [CPSR] in { @@ -1119,9 +1121,13 @@ BinOpFrag<(subc node:$LHS, node:$RHS)>>; defm t2ADC : T2I_adde_sube_irs<0b1010, "adc", - BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>; + BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>; defm t2SBC : T2I_adde_sube_irs<0b1011, "sbc", - BinOpFrag<(sube node:$LHS, node:$RHS)>>; + BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>; +defm t2ADCS : T2I_adde_sube_s_irs<0b1010, "adcs", + BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>; +defm t2SBCS : T2I_adde_sube_s_irs<0b1011, "sbcs", + BinOpFrag<(sube_live_carry node:$LHS, node:$RHS)>>; // RSB defm t2RSB : T2I_rbin_is <0b1110, "rsb", From bob.wilson at apple.com Tue Feb 16 14:49:04 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Feb 2010 20:49:04 -0000 Subject: [llvm-commits] [llvm] r96385 - /llvm/trunk/test/Transforms/GVN/pre-load.ll Message-ID: <201002162049.o1GKn8E3007621@zion.cs.uiuc.edu> Author: bwilson Date: Tue Feb 16 14:48:55 2010 New Revision: 96385 URL: http://llvm.org/viewvc/llvm-project?rev=96385&view=rev Log: Testcase for critical edge splitting with load PRE. Modified: llvm/trunk/test/Transforms/GVN/pre-load.ll Modified: llvm/trunk/test/Transforms/GVN/pre-load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/pre-load.ll?rev=96385&r1=96384&r2=96385&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/pre-load.ll (original) +++ llvm/trunk/test/Transforms/GVN/pre-load.ll Tue Feb 16 14:48:55 2010 @@ -362,3 +362,30 @@ return: ret void } + +; Test critical edge splitting. +define i32 @test11(i32* %p, i1 %C, i32 %N) { +; CHECK: @test11 +block1: + br i1 %C, label %block2, label %block3 + +block2: + %cond = icmp sgt i32 %N, 1 + br i1 %cond, label %block4, label %block5 +; CHECK: load i32* %p +; CHECK-NEXT: br label %block4 + +block3: + store i32 0, i32* %p + br label %block4 + +block4: + %PRE = load i32* %p + br label %block5 + +block5: + %ret = phi i32 [ 0, %block2 ], [ %PRE, %block4 ] + ret i32 %ret +; CHECK: block4: +; CHECK-NEXT: phi i32 +} From greened at obbligato.org Tue Feb 16 14:50:20 2010 From: greened at obbligato.org (David Greene) Date: Tue, 16 Feb 2010 20:50:20 -0000 Subject: [llvm-commits] [llvm] r96386 - in /llvm/trunk: docs/LangRef.html lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-02-11-NonTemporal.ll Message-ID: <201002162050.o1GKoM15007715@zion.cs.uiuc.edu> Author: greened Date: Tue Feb 16 14:50:18 2010 New Revision: 96386 URL: http://llvm.org/viewvc/llvm-project?rev=96386&view=rev Log: Add support for emitting non-temporal stores for DAGs marked non-temporal. Fix from r96241 for botched encoding of MOVNTDQ. Add documentation for !nontemporal metadata. Add a simpler movnt testcase. Added: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Modified: llvm/trunk/docs/LangRef.html llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=96386&r1=96385&r2=96386&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Feb 16 14:50:18 2010 @@ -4074,8 +4074,9 @@
    Syntax:
    -  <result> = load <ty>* <pointer>[, align <alignment>]
    -  <result> = volatile load <ty>* <pointer>[, align <alignment>]
    +  <result> = load <ty>* <pointer>[, align <alignment>][, !nontemporal !]
    +  <result> = volatile load <ty>* <pointer>[, align <alignment>][, !nontemporal !]
    +  ! = !{ i32 1 }
     
    Overview:
    @@ -4088,7 +4089,7 @@ marked as volatile, then the optimizer is not allowed to modify the number or order of execution of this load with other volatile load and store - instructions.

    + instructions.

    The optional constant "align" argument specifies the alignment of the operation (that is, the alignment of the memory address). A value of 0 or an @@ -4098,6 +4099,14 @@ alignment results in an undefined behavior. Underestimating the alignment may produce less efficient code. An alignment of 1 is always safe.

    +

    The optional !nontemporal metadata must reference a single metatadata + name corresponding to a metadata node with one i32 entry of + value 1. The existance of the !nontemporal metatadata on the + instruction tells the optimizer and code generator that this load is + not expected to be reused in the cache. The code generator may + select special instructions to save cache bandwidth, such as the + MOVNT intruction on x86.

    +
    Semantics:

    The location of memory pointed to is loaded. If the value being loaded is of scalar type then the number of bytes read does not exceed the minimum number @@ -4124,8 +4133,8 @@

    Syntax:
    -  store <ty> <value>, <ty>* <pointer>[, align <alignment>]                   ; yields {void}
    -  volatile store <ty> <value>, <ty>* <pointer>[, align <alignment>]          ; yields {void}
    +  store <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !]                   ; yields {void}
    +  volatile store <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !]          ; yields {void}
     
    Overview:
    @@ -4150,6 +4159,15 @@ alignment results in an undefined behavior. Underestimating the alignment may produce less efficient code. An alignment of 1 is always safe.

    +

    The optional !nontemporal metadata must reference a single metatadata + name corresponding to a metadata node with one i32 entry of + value 1. The existance of the !nontemporal metatadata on the + instruction tells the optimizer and code generator that this load is + not expected to be reused in the cache. The code generator may + select special instructions to save cache bandwidth, such as the + MOVNT intruction on x86.

    + +
    Semantics:

    The contents of memory are updated to contain '<value>' at the location specified by the '<pointer>' operand. If Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=96386&r1=96385&r2=96386&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Feb 16 14:50:18 2010 @@ -160,6 +160,32 @@ def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>; def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>; +// MOVNT Support +// Like 'store', but requires the non-temporal bit to be set +def nontemporalstore : PatFrag<(ops node:$val, node:$ptr), + (st node:$val, node:$ptr), [{ + if (StoreSDNode *ST = dyn_cast(N)) + return ST->isNonTemporal(); + return false; +}]>; + +def alignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), + (st node:$val, node:$ptr), [{ + if (StoreSDNode *ST = dyn_cast(N)) + return ST->isNonTemporal() && !ST->isTruncatingStore() && + ST->getAddressingMode() == ISD::UNINDEXED && + ST->getAlignment() >= 16; + return false; +}]>; + +def unalignednontemporalstore : PatFrag<(ops node:$val, node:$ptr), + (st node:$val, node:$ptr), [{ + if (StoreSDNode *ST = dyn_cast(N)) + return ST->isNonTemporal() && + ST->getAlignment() < 16; + return false; +}]>; + def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>; def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>; def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>; @@ -1013,10 +1039,33 @@ "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>; // Non-temporal stores -def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), +def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), "movntps\t{$src, $dst|$dst, $src}", [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>; +let AddedComplexity = 400 in { // Prefer non-temporal versions +def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntps\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; + +def MOVNTDQ_64mr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>; + +def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst), + (MOVNTDQ_64mr VR128:$src, addr:$dst)>; + +def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), + "movnti\t{$src, $dst|$dst, $src}", + [(nontemporalstore (i32 GR32:$src), addr:$dst)]>, + TB, Requires<[HasSSE2]>; + +def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), + "movnti\t{$src, $dst|$dst, $src}", + [(nontemporalstore (i64 GR64:$src), addr:$dst)]>, + TB, Requires<[HasSSE2]>; +} + // Load, store, and memory fence def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>; @@ -2298,17 +2347,30 @@ [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>; // Non-temporal stores -def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; -def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; -def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), +def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), + "movntpd\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; +def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; +def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), "movnti\t{$src, $dst|$dst, $src}", [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>, TB, Requires<[HasSSE2]>; +let AddedComplexity = 400 in { // Prefer non-temporal versions +def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntpd\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore(v2f64 VR128:$src), addr:$dst)]>; + +def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; + +def : Pat<(alignednontemporalstore (v4i32 VR128:$src), addr:$dst), + (MOVNTDQmr VR128:$src, addr:$dst)>; +} + // Flush cache def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src), "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>, Added: llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll?rev=96386&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-02-11-NonTemporal.ll Tue Feb 16 14:50:18 2010 @@ -0,0 +1,22 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s +; CHECK: movnt +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +!0 = metadata !{ i32 1 } + +define void @sub_(i32* noalias %n) { +"file movnt.f90, line 2, bb1": + %n1 = alloca i32*, align 8 + %i = alloca i32, align 4 + %"$LCS_0" = alloca i64, align 8 + %"$LCS_S2" = alloca <2 x double>, align 16 + %r9 = load <2 x double>* %"$LCS_S2", align 8 + %r10 = load i64* %"$LCS_0", align 8 + %r11 = inttoptr i64 %r10 to <2 x double>* + store <2 x double> %r9, <2 x double>* %r11, align 16, !nontemporal !0 + br label %"file movnt.f90, line 18, bb5" + +"file movnt.f90, line 18, bb5": + ret void +} From clattner at apple.com Tue Feb 16 14:53:52 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 16 Feb 2010 12:53:52 -0800 Subject: [llvm-commits] [llvm] r96377 - in /llvm/trunk: include/llvm/Transforms/Utils/BasicBlockUtils.h lib/Transforms/Scalar/GVN.cpp lib/Transforms/Utils/BasicBlockUtils.cpp In-Reply-To: <201002161949.o1GJnc0d004362@zion.cs.uiuc.edu> References: <201002161949.o1GJnc0d004362@zion.cs.uiuc.edu> Message-ID: <372FBBBF-C873-41F4-A3CE-8A0DCC35CF3B@apple.com> On Feb 16, 2010, at 11:49 AM, Bob Wilson wrote: > Author: bwilson > Date: Tue Feb 16 13:49:17 2010 > New Revision: 96377 > > URL: http://llvm.org/viewvc/llvm-project?rev=96377&view=rev > Log: > Refactor to share code to find the position of a basic block successor in the > terminator's list of successors. Thanks Bob, please name it "GetSuccessorNumber" so it is clear what it does, -Chris > > Modified: > llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h > llvm/trunk/lib/Transforms/Scalar/GVN.cpp > llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp > > Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=96377&r1=96376&r2=96377&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original) > +++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Tue Feb 16 13:49:17 2010 > @@ -102,6 +102,11 @@ > // > void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum); > > +/// SuccessorNumber - Search for the specified successor of basic block BB and > +/// return its position in the terminator instruction's list of successors. > +/// It is an error to call this with a block that is not a successor. > +unsigned SuccessorNumber(BasicBlock *BB, BasicBlock *Succ); > + > /// isCriticalEdge - Return true if the specified edge is a critical edge. > /// Critical edges are edges from a block with multiple successors to a block > /// with multiple predecessors. > > Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=96377&r1=96376&r2=96377&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Feb 16 13:49:17 2010 > @@ -2141,14 +2141,7 @@ > // We can't do PRE safely on a critical edge, so instead we schedule > // the edge to be split and perform the PRE the next time we iterate > // on the function. > - unsigned SuccNum = 0; > - for (unsigned i = 0, e = PREPred->getTerminator()->getNumSuccessors(); > - i != e; ++i) > - if (PREPred->getTerminator()->getSuccessor(i) == CurrentBlock) { > - SuccNum = i; > - break; > - } > - > + unsigned SuccNum = SuccessorNumber(PREPred, CurrentBlock); > if (isCriticalEdge(PREPred->getTerminator(), SuccNum)) { > toSplit.push_back(std::make_pair(PREPred->getTerminator(), SuccNum)); > continue; > > Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=96377&r1=96376&r2=96377&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Tue Feb 16 13:49:17 2010 > @@ -274,24 +274,30 @@ > ReplaceInstWithInst(TI, NewTI); > } > > -/// SplitEdge - Split the edge connecting specified block. Pass P must > -/// not be NULL. > -BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) { > - TerminatorInst *LatchTerm = BB->getTerminator(); > - unsigned SuccNum = 0; > +/// SuccessorNumber - Search for the specified successor of basic block BB and > +/// return its position in the terminator instruction's list of successors. > +/// It is an error to call this with a block that is not a successor. > +unsigned llvm::SuccessorNumber(BasicBlock *BB, BasicBlock *Succ) { > + TerminatorInst *Term = BB->getTerminator(); > #ifndef NDEBUG > - unsigned e = LatchTerm->getNumSuccessors(); > + unsigned e = Term->getNumSuccessors(); > #endif > for (unsigned i = 0; ; ++i) { > assert(i != e && "Didn't find edge?"); > - if (LatchTerm->getSuccessor(i) == Succ) { > - SuccNum = i; > - break; > - } > + if (Term->getSuccessor(i) == Succ) > + return i; > } > + return 0; > +} > + > +/// SplitEdge - Split the edge connecting specified block. Pass P must > +/// not be NULL. > +BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) { > + unsigned SuccNum = SuccessorNumber(BB, Succ); > > // If this is a critical edge, let SplitCriticalEdge do it. > - if (SplitCriticalEdge(BB->getTerminator(), SuccNum, P)) > + TerminatorInst *LatchTerm = BB->getTerminator(); > + if (SplitCriticalEdge(LatchTerm, SuccNum, P)) > return LatchTerm->getSuccessor(SuccNum); > > // If the edge isn't critical, then BB has a single successor or Succ has a > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Tue Feb 16 15:07:14 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Feb 2010 21:07:14 -0000 Subject: [llvm-commits] [llvm] r96387 - in /llvm/trunk: include/llvm/Transforms/Utils/BasicBlockUtils.h lib/Transforms/Scalar/GVN.cpp lib/Transforms/Utils/BasicBlockUtils.cpp Message-ID: <201002162107.o1GL7Fs0008527@zion.cs.uiuc.edu> Author: bwilson Date: Tue Feb 16 15:06:42 2010 New Revision: 96387 URL: http://llvm.org/viewvc/llvm-project?rev=96387&view=rev Log: Rename SuccessorNumber to GetSuccessorNumber. Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=96387&r1=96386&r2=96387&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Tue Feb 16 15:06:42 2010 @@ -102,10 +102,11 @@ // void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum); -/// SuccessorNumber - Search for the specified successor of basic block BB and -/// return its position in the terminator instruction's list of successors. -/// It is an error to call this with a block that is not a successor. -unsigned SuccessorNumber(BasicBlock *BB, BasicBlock *Succ); +/// GetSuccessorNumber - Search for the specified successor of basic block BB +/// and return its position in the terminator instruction's list of +/// successors. It is an error to call this with a block that is not a +/// successor. +unsigned GetSuccessorNumber(BasicBlock *BB, BasicBlock *Succ); /// isCriticalEdge - Return true if the specified edge is a critical edge. /// Critical edges are edges from a block with multiple successors to a block Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=96387&r1=96386&r2=96387&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Feb 16 15:06:42 2010 @@ -1594,7 +1594,7 @@ << Pred->getName() << "': " << *LI << '\n'); return false; } - unsigned SuccNum = SuccessorNumber(Pred, LoadBB); + unsigned SuccNum = GetSuccessorNumber(Pred, LoadBB); toSplit.push_back(std::make_pair(Pred->getTerminator(), SuccNum)); return false; } @@ -2151,7 +2151,7 @@ // We can't do PRE safely on a critical edge, so instead we schedule // the edge to be split and perform the PRE the next time we iterate // on the function. - unsigned SuccNum = SuccessorNumber(PREPred, CurrentBlock); + unsigned SuccNum = GetSuccessorNumber(PREPred, CurrentBlock); if (isCriticalEdge(PREPred->getTerminator(), SuccNum)) { toSplit.push_back(std::make_pair(PREPred->getTerminator(), SuccNum)); continue; Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=96387&r1=96386&r2=96387&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Tue Feb 16 15:06:42 2010 @@ -274,10 +274,11 @@ ReplaceInstWithInst(TI, NewTI); } -/// SuccessorNumber - Search for the specified successor of basic block BB and -/// return its position in the terminator instruction's list of successors. -/// It is an error to call this with a block that is not a successor. -unsigned llvm::SuccessorNumber(BasicBlock *BB, BasicBlock *Succ) { +/// GetSuccessorNumber - Search for the specified successor of basic block BB +/// and return its position in the terminator instruction's list of +/// successors. It is an error to call this with a block that is not a +/// successor. +unsigned llvm::GetSuccessorNumber(BasicBlock *BB, BasicBlock *Succ) { TerminatorInst *Term = BB->getTerminator(); #ifndef NDEBUG unsigned e = Term->getNumSuccessors(); @@ -293,7 +294,7 @@ /// SplitEdge - Split the edge connecting specified block. Pass P must /// not be NULL. BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) { - unsigned SuccNum = SuccessorNumber(BB, Succ); + unsigned SuccNum = GetSuccessorNumber(BB, Succ); // If this is a critical edge, let SplitCriticalEdge do it. TerminatorInst *LatchTerm = BB->getTerminator(); From grosbach at apple.com Tue Feb 16 15:07:48 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 16 Feb 2010 21:07:48 -0000 Subject: [llvm-commits] [llvm] r96388 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td Message-ID: <201002162107.o1GL7n8V008567@zion.cs.uiuc.edu> Author: grosbach Date: Tue Feb 16 15:07:46 2010 New Revision: 96388 URL: http://llvm.org/viewvc/llvm-project?rev=96388&view=rev Log: Remove trailing whitespace Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96388&r1=96387&r2=96388&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 15:07:46 2010 @@ -174,7 +174,7 @@ return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32; }]>; -def so_imm_neg : +def so_imm_neg : PatLeaf<(imm), [{ return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1; }], so_imm_neg_XFORM>; @@ -192,7 +192,7 @@ /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield /// e.g., 0xf000ffff def bf_inv_mask_imm : Operand, - PatLeaf<(imm), [{ + PatLeaf<(imm), [{ uint32_t v = (uint32_t)N->getZExtValue(); if (v == 0xffffffff) return 0; @@ -225,7 +225,7 @@ return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0; }], hi16>; -/// imm0_65535 predicate - True if the 32-bit immediate is in the range +/// imm0_65535 predicate - True if the 32-bit immediate is in the range /// [0.65535]. def imm0_65535 : PatLeaf<(i32 imm), [{ return (uint32_t)N->getZExtValue() < 65536; @@ -609,7 +609,7 @@ "@ ADJCALLSTACKUP $amt1", [(ARMcallseq_end timm:$amt1, timm:$amt2)]>; -def ADJCALLSTACKDOWN : +def ADJCALLSTACKDOWN : PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary, "@ ADJCALLSTACKDOWN $amt", [(ARMcallseq_start timm:$amt)]>; @@ -781,7 +781,7 @@ // let isReturn = 1, isTerminator = 1, isBarrier = 1 in - def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br, + def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br, "bx", "\tlr", [(ARMretflag)]> { let Inst{3-0} = 0b1110; let Inst{7-4} = 0b0001; @@ -929,7 +929,7 @@ } // isBarrier = 1 // FIXME: should be able to write a pattern for ARMBrcond, but can't use - // a two-value operand where a dag node expects two operands. :( + // a two-value operand where a dag node expects two operands. :( def Bcc : ABI<0b1010, (outs), (ins brtarget:$target), IIC_Br, "b", "\t$target", [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>; @@ -969,7 +969,7 @@ // // Load -let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in +let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr, "ldr", "\t$dst, $addr", [(set GPR:$dst, (load addrmode2:$addr))]>; @@ -985,7 +985,7 @@ IIC_iLoadr, "ldrh", "\t$dst, $addr", [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>; -def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, +def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr, "ldrb", "\t$dst, $addr", [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>; @@ -1082,42 +1082,42 @@ // Indexed stores def STR_PRE : AI2stwpr<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base, am2offset:$offset), + (ins GPR:$src, GPR:$base, am2offset:$offset), StFrm, IIC_iStoreru, "str", "\t$src, [$base, $offset]!", "$base = $base_wb", [(set GPR:$base_wb, (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>; def STR_POST : AI2stwpo<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base,am2offset:$offset), + (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm, IIC_iStoreru, "str", "\t$src, [$base], $offset", "$base = $base_wb", [(set GPR:$base_wb, (post_store GPR:$src, GPR:$base, am2offset:$offset))]>; def STRH_PRE : AI3sthpr<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base,am3offset:$offset), + (ins GPR:$src, GPR:$base,am3offset:$offset), StMiscFrm, IIC_iStoreru, "strh", "\t$src, [$base, $offset]!", "$base = $base_wb", [(set GPR:$base_wb, (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>; def STRH_POST: AI3sthpo<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base,am3offset:$offset), + (ins GPR:$src, GPR:$base,am3offset:$offset), StMiscFrm, IIC_iStoreru, "strh", "\t$src, [$base], $offset", "$base = $base_wb", [(set GPR:$base_wb, (post_truncsti16 GPR:$src, GPR:$base, am3offset:$offset))]>; def STRB_PRE : AI2stbpr<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base,am2offset:$offset), + (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm, IIC_iStoreru, "strb", "\t$src, [$base, $offset]!", "$base = $base_wb", [(set GPR:$base_wb, (pre_truncsti8 GPR:$src, GPR:$base, am2offset:$offset))]>; def STRB_POST: AI2stbpo<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base,am2offset:$offset), + (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm, IIC_iStoreru, "strb", "\t$src, [$base], $offset", "$base = $base_wb", [(set GPR:$base_wb, (post_truncsti8 GPR:$src, @@ -1126,7 +1126,7 @@ // STRT and STRBT are for disassembly only. def STRT : AI2stwpo<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base,am2offset:$offset), + (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm, IIC_iStoreru, "strt", "\t$src, [$base], $offset", "$base = $base_wb", [/* For disassembly only; pattern left blank */]> { @@ -1134,7 +1134,7 @@ } def STRBT : AI2stbpo<(outs GPR:$base_wb), - (ins GPR:$src, GPR:$base,am2offset:$offset), + (ins GPR:$src, GPR:$base,am2offset:$offset), StFrm, IIC_iStoreru, "strbt", "\t$src, [$base], $offset", "$base = $base_wb", [/* For disassembly only; pattern left blank */]> { @@ -1168,7 +1168,7 @@ let Inst{25} = 0; } -def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), +def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm, IIC_iMOVsr, "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP { let Inst{25} = 0; @@ -1181,7 +1181,7 @@ } let isReMaterializable = 1, isAsCheapAsAMove = 1 in -def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src), +def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src), DPFrm, IIC_iMOVi, "movw", "\t$dst, $src", [(set GPR:$dst, imm0_65535:$src)]>, @@ -1195,7 +1195,7 @@ DPFrm, IIC_iMOVi, "movt", "\t$dst, $imm", [(set GPR:$dst, - (or (and GPR:$src, 0xffff), + (or (and GPR:$src, 0xffff), lo16AllZero:$imm))]>, UnaryDP, Requires<[IsARM, HasV6T2]> { let Inst{20} = 0; @@ -1214,7 +1214,7 @@ // due to flag operands. let Defs = [CPSR] in { -def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, +def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi, "movs", "\t$dst, $src, lsr #1", [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP; def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, @@ -1447,7 +1447,7 @@ let Inst{25} = 0; } let isReMaterializable = 1, isAsCheapAsAMove = 1 in -def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm, +def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm, IIC_iMOVi, "mvn", "\t$dst, $imm", [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP { let Inst{25} = 1; @@ -1796,7 +1796,7 @@ // Conditional moves // FIXME: should be able to write a pattern for ARMcmov, but can't use -// a two-value operand where a dag node expects two operands. :( +// a two-value operand where a dag node expects two operands. :( def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm, IIC_iCMOVr, "mov", "\t$dst, $true", [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>, @@ -2076,7 +2076,7 @@ // Two piece so_imms. let isReMaterializable = 1 in -def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src), +def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src), Pseudo, IIC_iMOVi, "mov", "\t$dst, $src", [(set GPR:$dst, so_imm2part:$src)]>, Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=96388&r1=96387&r2=96388&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Feb 16 15:07:46 2010 @@ -236,20 +236,20 @@ D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in { // Also used for Thumb2 def tBL : TIx2<0b11110, 0b11, 1, - (outs), (ins i32imm:$func, variable_ops), IIC_Br, + (outs), (ins i32imm:$func, variable_ops), IIC_Br, "bl\t${func:call}", [(ARMtcall tglobaladdr:$func)]>, Requires<[IsThumb, IsNotDarwin]>; // ARMv5T and above, also used for Thumb2 def tBLXi : TIx2<0b11110, 0b11, 0, - (outs), (ins i32imm:$func, variable_ops), IIC_Br, + (outs), (ins i32imm:$func, variable_ops), IIC_Br, "blx\t${func:call}", [(ARMcall tglobaladdr:$func)]>, Requires<[IsThumb, HasV5T, IsNotDarwin]>; // Also used for Thumb2 - def tBLXr : TI<(outs), (ins GPR:$func, variable_ops), IIC_Br, + def tBLXr : TI<(outs), (ins GPR:$func, variable_ops), IIC_Br, "blx\t$func", [(ARMtcall GPR:$func)]>, Requires<[IsThumb, HasV5T, IsNotDarwin]>, @@ -257,7 +257,7 @@ // ARMv4T def tBX : TIx2<{?,?,?,?,?}, {?,?}, ?, - (outs), (ins tGPR:$func, variable_ops), IIC_Br, + (outs), (ins tGPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", [(ARMcall_nolink tGPR:$func)]>, Requires<[IsThumb1Only, IsNotDarwin]>; @@ -271,20 +271,20 @@ D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in { // Also used for Thumb2 def tBLr9 : TIx2<0b11110, 0b11, 1, - (outs), (ins i32imm:$func, variable_ops), IIC_Br, + (outs), (ins i32imm:$func, variable_ops), IIC_Br, "bl\t${func:call}", [(ARMtcall tglobaladdr:$func)]>, Requires<[IsThumb, IsDarwin]>; // ARMv5T and above, also used for Thumb2 def tBLXi_r9 : TIx2<0b11110, 0b11, 0, - (outs), (ins i32imm:$func, variable_ops), IIC_Br, + (outs), (ins i32imm:$func, variable_ops), IIC_Br, "blx\t${func:call}", [(ARMcall tglobaladdr:$func)]>, Requires<[IsThumb, HasV5T, IsDarwin]>; // Also used for Thumb2 - def tBLXr_r9 : TI<(outs), (ins GPR:$func, variable_ops), IIC_Br, + def tBLXr_r9 : TI<(outs), (ins GPR:$func, variable_ops), IIC_Br, "blx\t$func", [(ARMtcall GPR:$func)]>, Requires<[IsThumb, HasV5T, IsDarwin]>, @@ -292,7 +292,7 @@ // ARMv4T def tBXr9 : TIx2<{?,?,?,?,?}, {?,?}, ?, - (outs), (ins tGPR:$func, variable_ops), IIC_Br, + (outs), (ins tGPR:$func, variable_ops), IIC_Br, "mov\tlr, pc\n\tbx\t$func", [(ARMcall_nolink tGPR:$func)]>, Requires<[IsThumb1Only, IsDarwin]>; @@ -307,7 +307,7 @@ // Far jump let Defs = [LR] in - def tBfar : TIx2<0b11110, 0b11, 1, (outs), (ins brtarget:$target), IIC_Br, + def tBfar : TIx2<0b11110, 0b11, 1, (outs), (ins brtarget:$target), IIC_Br, "bl\t$target\t@ far jump",[]>; def tBR_JTr : T1JTI<(outs), @@ -345,11 +345,11 @@ // let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in -def tLDR : T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr), IIC_iLoadr, +def tLDR : T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr), IIC_iLoadr, "ldr", "\t$dst, $addr", [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>, T1LdSt<0b100>; -def tLDRi: T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr), IIC_iLoadr, +def tLDRi: T1pI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr), IIC_iLoadr, "ldr", "\t$dst, $addr", []>, T1LdSt4Imm<{1,?,?}>; @@ -399,7 +399,7 @@ // Load tconstpool // FIXME: Use ldr.n to work around a Darwin assembler bug. -let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in +let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in def tLDRpci : T1pIs<(outs tGPR:$dst), (ins i32imm:$addr), IIC_iLoadi, "ldr", ".n\t$dst, $addr", [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>, Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=96388&r1=96387&r2=96388&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Feb 16 15:07:46 2010 @@ -53,10 +53,10 @@ // bits [bits 0-7], the 4-bit shift/splat amount is the next 4 bits [bits 8-11]. def t2_so_imm : Operand, PatLeaf<(imm), [{ - return ARM_AM::getT2SOImmVal((uint32_t)N->getZExtValue()) != -1; + return ARM_AM::getT2SOImmVal((uint32_t)N->getZExtValue()) != -1; }]>; -// t2_so_imm_not - Match an immediate that is a complement +// t2_so_imm_not - Match an immediate that is a complement // of a t2_so_imm. def t2_so_imm_not : Operand, PatLeaf<(imm), [{ @@ -114,13 +114,13 @@ return (uint32_t)N->getZExtValue() < 4096; }]>; -def imm0_4095_neg : PatLeaf<(i32 imm), [{ - return (uint32_t)(-N->getZExtValue()) < 4096; -}], imm_neg_XFORM>; +def imm0_4095_neg : PatLeaf<(i32 imm), [{ + return (uint32_t)(-N->getZExtValue()) < 4096; +}], imm_neg_XFORM>; def imm0_255_neg : PatLeaf<(i32 imm), [{ return (uint32_t)(-N->getZExtValue()) < 255; -}], imm_neg_XFORM>; +}], imm_neg_XFORM>; // Define Thumb2 specific addressing modes. @@ -208,7 +208,7 @@ /// T2I_bin_irs - Defines a set of (op reg, {so_imm|r|so_reg}) patterns for a // binary operation that produces a value. These are predicable and can be /// changed to modify CPSR. -multiclass T2I_bin_irs opcod, string opc, PatFrag opnode, +multiclass T2I_bin_irs opcod, string opc, PatFrag opnode, bit Commutable = 0, string wide =""> { // shifted imm def ri : T2sI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi, @@ -736,7 +736,7 @@ let Inst{19-16} = 0b1101; // Rn = sp let Inst{15} = 0; } -def t2ADDrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm), +def t2ADDrSPi12 : T2I<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm), IIC_iALUi, "addw", "\t$dst, $sp, $imm", []> { let Inst{31-27} = 0b11110; let Inst{25} = 1; @@ -805,7 +805,7 @@ // // Load -let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in +let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in defm t2LDR : T2I_ld<0, 0b10, "ldr", UnOpFrag<(load node:$Src)>>; // Loads with zero extension @@ -1649,7 +1649,7 @@ // Conditional moves // FIXME: should be able to write a pattern for ARMcmov, but can't use -// a two-value operand where a dag node expects two operands. :( +// a two-value operand where a dag node expects two operands. :( def t2MOVCCr : T2I<(outs GPR:$dst), (ins GPR:$false, GPR:$true), IIC_iCMOVr, "mov", ".w\t$dst, $true", [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>, @@ -1976,7 +1976,7 @@ // Pseudo instruction that combines ldr from constpool and add pc. This should // be expanded into two instructions late to allow if-conversion and // scheduling. -let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in +let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in def t2LDRpci_pic : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr, pclabel:$cp), NoItinerary, "@ ldr.w\t$dst, $addr\n$cp:\n\tadd\t$dst, pc", [(set GPR:$dst, (ARMpic_add (load (ARMWrapper tconstpool:$addr)), From evan.cheng at apple.com Tue Feb 16 15:09:53 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 16 Feb 2010 21:09:53 -0000 Subject: [llvm-commits] [llvm] r96389 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/lsr-reuse-trunc.ll test/CodeGen/X86/sink-hoist.ll Message-ID: <201002162109.o1GL9vwF008724@zion.cs.uiuc.edu> Author: evancheng Date: Tue Feb 16 15:09:44 2010 New Revision: 96389 URL: http://llvm.org/viewvc/llvm-project?rev=96389&view=rev Log: Look for SSE and instructions of this form: (and x, (build_vector c1,c2,c3,c4)). If there exists a use of a build_vector that's the bitwise complement of the mask, then transform the node to (and (xor x, (build_vector -1,-1,-1,-1)), (build_vector ~c1,~c2,~c3,~c4)). Since this transformation is only useful when 1) the given build_vector will become a load from constpool, and 2) (and (xor x -1), y) matches to a single instruction, I decided this is appropriate as a x86 specific transformation. rdar://7323335 Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll llvm/trunk/test/CodeGen/X86/sink-hoist.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=96389&r1=96388&r2=96389&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Feb 16 15:09:44 2010 @@ -990,6 +990,7 @@ setTargetDAGCombine(ISD::VECTOR_SHUFFLE); setTargetDAGCombine(ISD::BUILD_VECTOR); setTargetDAGCombine(ISD::SELECT); + setTargetDAGCombine(ISD::AND); setTargetDAGCombine(ISD::SHL); setTargetDAGCombine(ISD::SRA); setTargetDAGCombine(ISD::SRL); @@ -9157,6 +9158,53 @@ return SDValue(); } +/// PerformANDCombine - Look for SSE and instructions of this form: +/// (and x, (build_vector c1,c2,c3,c4)). If there exists a use of a build_vector +/// that's the bitwise complement of the mask, then transform the node to +/// (and (xor x, (build_vector -1,-1,-1,-1)), (build_vector ~c1,~c2,~c3,~c4)). +static SDValue PerformANDCombine(SDNode *N, SelectionDAG &DAG, + TargetLowering::DAGCombinerInfo &DCI) { + EVT VT = N->getValueType(0); + if (!VT.isVector() || !VT.isInteger()) + return SDValue(); + + SDValue N0 = N->getOperand(0); + SDValue N1 = N->getOperand(1); + if (N0.getOpcode() == ISD::XOR || !N1.hasOneUse()) + return SDValue(); + + if (N1.getOpcode() == ISD::BUILD_VECTOR) { + unsigned NumElts = VT.getVectorNumElements(); + EVT EltVT = VT.getVectorElementType(); + SmallVector Mask; + Mask.reserve(NumElts); + for (unsigned i = 0; i != NumElts; ++i) { + SDValue Arg = N1.getOperand(i); + if (Arg.getOpcode() == ISD::UNDEF) { + Mask.push_back(Arg); + continue; + } + ConstantSDNode *C = dyn_cast(Arg); + if (!C) return SDValue(); + Mask.push_back(DAG.getConstant(~C->getAPIntValue(), EltVT)); + } + N1 = DAG.getNode(ISD::BUILD_VECTOR, N1.getDebugLoc(), VT, + &Mask[0], NumElts); + if (!N1.use_empty()) { + unsigned Bits = EltVT.getSizeInBits(); + Mask.clear(); + for (unsigned i = 0; i != NumElts; ++i) + Mask.push_back(DAG.getConstant(APInt::getAllOnesValue(Bits), EltVT)); + SDValue NewMask = DAG.getNode(ISD::BUILD_VECTOR, N->getDebugLoc(), + VT, &Mask[0], NumElts); + return DAG.getNode(ISD::AND, N->getDebugLoc(), VT, + DAG.getNode(ISD::XOR, N->getDebugLoc(), VT, + N0, NewMask), N1); + } + } + + return SDValue(); +} /// PerformMulCombine - Optimize a single multiply with constant into two /// in order to implement it with two cheaper instructions, e.g. @@ -9305,7 +9353,7 @@ } } else if (InVec.getOpcode() == ISD::INSERT_VECTOR_ELT) { if (ConstantSDNode *C = dyn_cast(InVec.getOperand(2))) { - unsigned SplatIdx = cast(ShAmtOp)->getSplatIndex(); + unsigned SplatIdx= cast(ShAmtOp)->getSplatIndex(); if (C->getZExtValue() == SplatIdx) BaseShAmt = InVec.getOperand(1); } @@ -9690,6 +9738,7 @@ case ISD::VECTOR_SHUFFLE: return PerformShuffleCombine(N, DAG, *this); case ISD::SELECT: return PerformSELECTCombine(N, DAG, Subtarget); case X86ISD::CMOV: return PerformCMOVCombine(N, DAG, DCI); + case ISD::AND: return PerformANDCombine(N, DAG, DCI); case ISD::MUL: return PerformMulCombine(N, DAG, DCI); case ISD::SHL: case ISD::SRA: Modified: llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll?rev=96389&r1=96388&r2=96389&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll (original) +++ llvm/trunk/test/CodeGen/X86/lsr-reuse-trunc.ll Tue Feb 16 15:09:44 2010 @@ -1,10 +1,19 @@ -; RUN: llc < %s -march=x86-64 | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s ; Full strength reduction wouldn't reduce register pressure, so LSR should ; stick with indexing here. -; CHECK: movaps (%rsi,%rax,4), %xmm3 -; CHECK: movaps %xmm3, (%rdi,%rax,4) +; Also checks andps and andnps shares the same constantpool. Previously llvm +; will codegen two andps, one using 0x80000000, the other 0x7fffffff. +; rdar://7323335 + +; CHECK: movaps LCPI1_0 +; CHECK: movaps LCPI1_1 +; CHECK-NOT: movaps LCPI1_2 +; CHECK: movaps (%rsi,%rax,4), %xmm2 +; CHECK: andps +; CHECK: andnps +; CHECK: movaps %xmm2, (%rdi,%rax,4) ; CHECK: addq $4, %rax ; CHECK: cmpl %eax, (%rdx) ; CHECK-NEXT: jg Modified: llvm/trunk/test/CodeGen/X86/sink-hoist.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sink-hoist.ll?rev=96389&r1=96388&r2=96389&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sink-hoist.ll (original) +++ llvm/trunk/test/CodeGen/X86/sink-hoist.ll Tue Feb 16 15:09:44 2010 @@ -63,7 +63,6 @@ ; CHECK: vv: ; CHECK: LCPI4_0(%rip), %xmm0 ; CHECK: LCPI4_1(%rip), %xmm1 -; CHECK: LCPI4_2(%rip), %xmm2 ; CHECK: align ; CHECK-NOT: LCPI ; CHECK: ret From dpatel at apple.com Tue Feb 16 15:16:21 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 16 Feb 2010 21:16:21 -0000 Subject: [llvm-commits] [llvm] r96391 - /llvm/trunk/test/FrontendC/2010-02-15-DbgStaticVar.c Message-ID: <201002162116.o1GLGM8g009083@zion.cs.uiuc.edu> Author: dpatel Date: Tue Feb 16 15:16:08 2010 New Revision: 96391 URL: http://llvm.org/viewvc/llvm-project?rev=96391&view=rev Log: New testcase. Added: llvm/trunk/test/FrontendC/2010-02-15-DbgStaticVar.c Added: llvm/trunk/test/FrontendC/2010-02-15-DbgStaticVar.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-02-15-DbgStaticVar.c?rev=96391&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2010-02-15-DbgStaticVar.c (added) +++ llvm/trunk/test/FrontendC/2010-02-15-DbgStaticVar.c Tue Feb 16 15:16:08 2010 @@ -0,0 +1,13 @@ +// RUN: %llvmgcc -g -S %s -o - | grep "metadata ..b., metadata ..b., metadata ...," +// Test to check intentionally empty linkage name for a static variable. +// Radar 7651244. +static int foo(int a) +{ + static int b = 1; + return b+a; +} + +int main() { + int j = foo(1); + return 0; +} From grosbach at apple.com Tue Feb 16 15:23:04 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 16 Feb 2010 21:23:04 -0000 Subject: [llvm-commits] [llvm] r96393 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td Message-ID: <201002162123.o1GLN6ng009459@zion.cs.uiuc.edu> Author: grosbach Date: Tue Feb 16 15:23:02 2010 New Revision: 96393 URL: http://llvm.org/viewvc/llvm-project?rev=96393&view=rev Log: 80 column cleanup Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96393&r1=96392&r2=96393&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 15:23:02 2010 @@ -523,7 +523,8 @@ Requires<[IsARM, HasV6]> { let Inst{11-10} = 0b00; } - def rr_rot : AExtI, @@ -771,7 +772,7 @@ "(${label}_${id}-(", "${:private}PCRELL${:uid}+8))\n"), !strconcat("${:private}PCRELL${:uid}:\n\t", - "add$p\t$dst, pc, #${:private}PCRELV${:uid}")), + "add$p\t$dst, pc, #${:private}PCRELV${:uid}")), []> { let Inst{25} = 1; } @@ -1066,8 +1067,8 @@ [(store GPR:$src, addrmode2:$addr)]>; // Stores with truncate -def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, IIC_iStorer, - "strh", "\t$src, $addr", +def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, + IIC_iStorer, "strh", "\t$src, $addr", [(truncstorei16 GPR:$src, addrmode3:$addr)]>; def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer, @@ -1596,7 +1597,7 @@ def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc", [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16), - (sra GPR:$b, (i32 16)))))]>, + (sra GPR:$b, (i32 16)))))]>, Requires<[IsARM, HasV5TE]> { let Inst{5} = 0; let Inst{6} = 1; @@ -2101,7 +2102,7 @@ // FIXME: Remove this when we can do generalized remat. let isReMaterializable = 1 in def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi, - "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}", + "movw", "\t$dst, ${src:lo16}\n\tmovt${p}\t$dst, ${src:hi16}", [(set GPR:$dst, (i32 imm:$src))]>, Requires<[IsARM, HasV6T2]>; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=96393&r1=96392&r2=96393&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Feb 16 15:23:02 2010 @@ -208,7 +208,7 @@ let Inst{6-3} = 0b1110; // Rm = lr } // Alternative return instruction used by vararg functions. - def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), IIC_Br, "bx\t$target", []>, + def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), IIC_Br, "bx\t$target",[]>, T1Special<{1,1,0,?}>; // A6.2.3 & A8.6.25 } @@ -769,7 +769,7 @@ T1Misc<{0,0,1,0,1,0,?}>; -// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation. +// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC operation. // Expanded after instruction selection into a branch sequence. let usesCustomInserter = 1 in // Expanded after instruction selection. def tMOVCCr_pseudo : Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=96393&r1=96392&r2=96393&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Feb 16 15:23:02 2010 @@ -371,7 +371,8 @@ /// for a binary operation that produces a value and use the carry /// bit. It's not predicable. let Uses = [CPSR] in { -multiclass T2I_adde_sube_irs opcod, string opc, PatFrag opnode, bit Commutable = 0> { +multiclass T2I_adde_sube_irs opcod, string opc, PatFrag opnode, + bit Commutable = 0> { // shifted imm def ri : T2sI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi, opc, "\t$dst, $lhs, $rhs", @@ -411,7 +412,8 @@ // Carry setting variants let Defs = [CPSR] in { -multiclass T2I_adde_sube_s_irs opcod, string opc, PatFrag opnode, bit Commutable = 0> { +multiclass T2I_adde_sube_s_irs opcod, string opc, PatFrag opnode, + bit Commutable = 0> { // shifted imm def Sri : T2sI<(outs GPR:$dst), (ins GPR:$lhs, t2_so_imm:$rhs), IIC_iALUi, opc, "\t$dst, $lhs, $rhs", @@ -928,9 +930,9 @@ } // Store -defm t2STR : T2I_st<0b10, "str", BinOpFrag<(store node:$LHS, node:$RHS)>>; -defm t2STRB : T2I_st<0b00, "strb", BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>; -defm t2STRH : T2I_st<0b01, "strh", BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>; +defm t2STR :T2I_st<0b10,"str", BinOpFrag<(store node:$LHS, node:$RHS)>>; +defm t2STRB:T2I_st<0b00,"strb",BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>; +defm t2STRH:T2I_st<0b01,"strh",BinOpFrag<(truncstorei16 node:$LHS, node:$RHS)>>; // Store doubleword let mayLoad = 1, hasExtraSrcRegAllocReq = 1 in @@ -991,7 +993,7 @@ let mayLoad = 1, hasExtraDefRegAllocReq = 1 in def t2LDM : T2XI<(outs), (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops), - IIC_iLoadm, "ldm${addr:submode}${p}${addr:wide}\t$addr, $wb", []> { + IIC_iLoadm, "ldm${addr:submode}${p}${addr:wide}\t$addr, $wb", []> { let Inst{31-27} = 0b11101; let Inst{26-25} = 0b00; let Inst{24-23} = {?, ?}; // IA: '01', DB: '10' @@ -1003,7 +1005,7 @@ let mayStore = 1, hasExtraSrcRegAllocReq = 1 in def t2STM : T2XI<(outs), (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops), - IIC_iStorem, "stm${addr:submode}${p}${addr:wide}\t$addr, $wb", []> { + IIC_iStorem, "stm${addr:submode}${p}${addr:wide}\t$addr, $wb", []> { let Inst{31-27} = 0b11101; let Inst{26-25} = 0b00; let Inst{24-23} = {?, ?}; // IA: '01', DB: '10' @@ -1472,7 +1474,7 @@ def BT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc", [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16), - (sra GPR:$b, (i32 16)))))]> { + (sra GPR:$b, (i32 16)))))]> { let Inst{31-27} = 0b11111; let Inst{26-23} = 0b0110; let Inst{22-20} = 0b001; @@ -1496,7 +1498,7 @@ def TT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc", [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)), - (sra GPR:$b, (i32 16)))))]> { + (sra GPR:$b, (i32 16)))))]> { let Inst{31-27} = 0b11111; let Inst{26-23} = 0b0110; let Inst{22-20} = 0b001; @@ -1508,7 +1510,7 @@ def WB : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc", [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a, - (sext_inreg GPR:$b, i16)), (i32 16))))]> { + (sext_inreg GPR:$b, i16)), (i32 16))))]> { let Inst{31-27} = 0b11111; let Inst{26-23} = 0b0110; let Inst{22-20} = 0b011; @@ -1520,7 +1522,7 @@ def WT : T2I<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc", [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a, - (sra GPR:$b, (i32 16))), (i32 16))))]> { + (sra GPR:$b, (i32 16))), (i32 16))))]> { let Inst{31-27} = 0b11111; let Inst{26-23} = 0b0110; let Inst{22-20} = 0b011; @@ -1541,8 +1543,8 @@ // Misc. Arithmetic Instructions. // -class T2I_misc op1, bits<2> op2, dag oops, dag iops, InstrItinClass itin, - string opc, string asm, list pattern> +class T2I_misc op1, bits<2> op2, dag oops, dag iops, + InstrItinClass itin, string opc, string asm, list pattern> : T2I { let Inst{31-27} = 0b11111; let Inst{26-22} = 0b01010; From dag at cray.com Tue Feb 16 15:23:09 2010 From: dag at cray.com (David Greene) Date: Tue, 16 Feb 2010 15:23:09 -0600 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp In-Reply-To: <1B1B8041-800F-4D49-8E98-B529239C1198@apple.com> References: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> <74c447501002152224h7c83b568j4e1963122cd886ee@mail.gmail.com> <1B1B8041-800F-4D49-8E98-B529239C1198@apple.com> Message-ID: <201002161523.09821.dag@cray.com> On Tuesday 16 February 2010 00:36:23 Chris Lattner wrote: one of those testing methodology types... ;] > > I don't like it (if it creeps beyond this) because it adds more uses of the > C++ API, meaning that the tests need to be updated when the API changes. > Why not use the stable C api for stuff like this? On the other hand, tests like this encourage people to think more about API changes and what is really necessary. I don't see that as a bad thing. It won't prevent changes but might encourage people to think more about what they're doing and/or provide backward-compatibility if appropriate. -Dave From dpatel at apple.com Tue Feb 16 15:39:51 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 16 Feb 2010 21:39:51 -0000 Subject: [llvm-commits] [llvm] r96395 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <201002162139.o1GLdrwl010378@zion.cs.uiuc.edu> Author: dpatel Date: Tue Feb 16 15:39:34 2010 New Revision: 96395 URL: http://llvm.org/viewvc/llvm-project?rev=96395&view=rev Log: Use line and column number to distinguish two lexical blocks at the same level. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=96395&r1=96394&r2=96395&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Feb 16 15:39:34 2010 @@ -459,9 +459,11 @@ if (DbgNode && !isLexicalBlock()) DbgNode = 0; } - DIScope getContext() const { return getFieldAs(1); } - StringRef getDirectory() const { return getContext().getDirectory(); } - StringRef getFilename() const { return getContext().getFilename(); } + DIScope getContext() const { return getFieldAs(1); } + StringRef getDirectory() const { return getContext().getDirectory(); } + StringRef getFilename() const { return getContext().getFilename(); } + unsigned getLineNumber() const { return getUnsignedField(2); } + unsigned getColumnNumber() const { return getUnsignedField(3); } }; /// DINameSpace - A wrapper for a C++ style name space. @@ -636,7 +638,8 @@ /// CreateLexicalBlock - This creates a descriptor for a lexical block /// with the specified parent context. - DILexicalBlock CreateLexicalBlock(DIDescriptor Context); + DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0, + unsigned Col = 0); /// CreateNameSpace - This creates new descriptor for a namespace /// with the specified parent context. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=96395&r1=96394&r2=96395&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Feb 16 15:39:34 2010 @@ -1007,12 +1007,15 @@ /// CreateBlock - This creates a descriptor for a lexical block with the /// specified parent VMContext. -DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context) { +DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context, + unsigned LineNo, unsigned Col) { Value *Elts[] = { GetTagConstant(dwarf::DW_TAG_lexical_block), - Context.getNode() + Context.getNode(), + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + ConstantInt::get(Type::getInt32Ty(VMContext), Col) }; - return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 2)); + return DILexicalBlock(MDNode::get(VMContext, &Elts[0], 4)); } /// CreateNameSpace - This creates new descriptor for a namespace From isanbard at gmail.com Tue Feb 16 15:50:53 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Feb 2010 21:50:53 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96398 - in /llvm-gcc-4.2/trunk/gcc: ada/sinfo.ads objc/objc-act.c Message-ID: <201002162151.o1GLp6v8011052@zion.cs.uiuc.edu> Author: void Date: Tue Feb 16 15:50:11 2010 New Revision: 96398 URL: http://llvm.org/viewvc/llvm-project?rev=96398&view=rev Log: s/implemenation/implementation/ Modified: llvm-gcc-4.2/trunk/gcc/ada/sinfo.ads llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/ada/sinfo.ads URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/sinfo.ads?rev=96398&r1=96397&r2=96398&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ada/sinfo.ads (original) +++ llvm-gcc-4.2/trunk/gcc/ada/sinfo.ads Tue Feb 16 15:50:11 2010 @@ -1149,7 +1149,7 @@ -- Is_Protected_Subprogram_Body (Flag7-Sem) -- A flag set in a Subprogram_Body block to indicate that it is the - -- implemenation of a protected subprogram. Such a body needs cleanup + -- implementation of a protected subprogram. Such a body needs cleanup -- handler to make sure that the associated protected object is unlocked -- when the subprogram completes. Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=96398&r1=96397&r2=96398&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Feb 16 15:50:11 2010 @@ -1274,7 +1274,7 @@ } if (objc_implementation_context) { - error ("property cannot be declared inside @implemenation context"); + error ("property cannot be declared inside @implementation context"); return; } else if (!objc_interface_context) @@ -10241,7 +10241,7 @@ } -/* Build following types which represent each class implemenation. +/* Build following types which represent each class implementation. struct class_t { struct class_t *isa; @@ -16809,7 +16809,7 @@ /* APPLE LOCAL end radar 4966565 */ /* Main routine to generate code/data for all the property information for - current implemenation (class or category). CLASS is the interface where + current implementation (class or category). CLASS is the interface where ivars are declared in. CLASS_METHODS is where methods are found which could be a class or a category depending on wheter we are implementing property of a class or a category. */ From clattner at apple.com Tue Feb 16 15:53:09 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 16 Feb 2010 13:53:09 -0800 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp In-Reply-To: <201002161523.09821.dag@cray.com> References: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> <74c447501002152224h7c83b568j4e1963122cd886ee@mail.gmail.com> <1B1B8041-800F-4D49-8E98-B529239C1198@apple.com> <201002161523.09821.dag@cray.com> Message-ID: <89F93CB3-D858-4F68-97B6-11B7E4F47FC2@apple.com> On Feb 16, 2010, at 1:23 PM, David Greene wrote: > On Tuesday 16 February 2010 00:36:23 Chris Lattner wrote: > one of those testing methodology types... ;] >> >> I don't like it (if it creeps beyond this) because it adds more uses of the >> C++ API, meaning that the tests need to be updated when the API changes. >> Why not use the stable C api for stuff like this? > > On the other hand, tests like this encourage people to think more about > API changes and what is really necessary. I don't see that as a bad thing. > It won't prevent changes but might encourage people to think more about > what they're doing and/or provide backward-compatibility if appropriate. I completely disagree, we are not interesting in avoiding api changes because of inconvenience. -Chris From dalej at apple.com Tue Feb 16 15:53:29 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Feb 2010 21:53:29 -0000 Subject: [llvm-commits] [llvm] r96399 - /llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td Message-ID: <201002162153.o1GLrTQg011142@zion.cs.uiuc.edu> Author: johannes Date: Tue Feb 16 15:53:27 2010 New Revision: 96399 URL: http://llvm.org/viewvc/llvm-project?rev=96399&view=rev Log: Really reserve R2 on PPC Darwin. PR 6314. Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td?rev=96399&r1=96398&r2=96399&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.td Tue Feb 16 15:53:27 2010 @@ -287,10 +287,8 @@ GPRCClass::allocation_order_begin(const MachineFunction &MF) const { // 32-bit SVR4 ABI: r2 is reserved for the OS. // 64-bit SVR4 ABI: r2 is reserved for the TOC pointer. - if (!MF.getTarget().getSubtarget().isDarwin()) - return begin()+1; - - return begin(); + // Darwin: R2 is reserved for CR save/restore sequence. + return begin()+1; } GPRCClass::iterator GPRCClass::allocation_order_end(const MachineFunction &MF) const { @@ -325,10 +323,8 @@ G8RCClass::iterator G8RCClass::allocation_order_begin(const MachineFunction &MF) const { // 64-bit SVR4 ABI: r2 is reserved for the TOC pointer. - if (!MF.getTarget().getSubtarget().isDarwin()) - return begin()+1; - - return begin(); + // Darwin: r2 is reserved for CR save/restore sequence. + return begin()+1; } G8RCClass::iterator G8RCClass::allocation_order_end(const MachineFunction &MF) const { From johnny.chen at apple.com Tue Feb 16 15:59:59 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 16 Feb 2010 21:59:59 -0000 Subject: [llvm-commits] [llvm] r96401 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002162200.o1GM0363011442@zion.cs.uiuc.edu> Author: johnny Date: Tue Feb 16 15:59:54 2010 New Revision: 96401 URL: http://llvm.org/viewvc/llvm-project?rev=96401&view=rev Log: Add SMC (Secure Monitor Call) system instruction for disassembly only. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96401&r1=96400&r2=96401&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Feb 16 15:59:54 2010 @@ -944,6 +944,13 @@ let Inst{7-4} = 0b0010; } +// Secure Monitor Call is a system instruction -- for disassembly only +def SMC : ABI<0b0001, (outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt", + [/* For disassembly only; pattern left blank */]> { + let Inst{23-20} = 0b0110; + let Inst{7-4} = 0b0111; +} + // Supervisor Call (Software Interrupt) -- for disassembly only let isCall = 1 in { def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc", @@ -951,8 +958,8 @@ } // Store Return State -- for disassembly only -def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$opt), - NoItinerary, "srs${addr:submode}\tsp!, $opt", +def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode), + NoItinerary, "srs${addr:submode}\tsp!, $mode", [/* For disassembly only; pattern left blank */]> { let Inst{31-28} = 0b1111; let Inst{22-20} = 0b110; // W = 1 From bob.wilson at apple.com Tue Feb 16 16:02:00 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Feb 2010 22:02:00 -0000 Subject: [llvm-commits] [llvm] r96402 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <201002162202.o1GM20AW011541@zion.cs.uiuc.edu> Author: bwilson Date: Tue Feb 16 16:01:59 2010 New Revision: 96402 URL: http://llvm.org/viewvc/llvm-project?rev=96402&view=rev Log: Handle tGPR register class in a few more places. This fixes some llvm-gcc build failures due to my fix for pr6111. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=96402&r1=96401&r2=96402&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Feb 16 16:01:59 2010 @@ -704,6 +704,11 @@ MFI.getObjectSize(FI), Align); + // tGPR is used sometimes in ARM instructions that need to avoid using + // certain registers. Just treat it as GPR here. + if (RC == ARM::tGPRRegisterClass) + RC = ARM::GPRRegisterClass; + if (RC == ARM::GPRRegisterClass) { AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::STR)) .addReg(SrcReg, getKillRegState(isKill)) @@ -752,6 +757,11 @@ MFI.getObjectSize(FI), Align); + // tGPR is used sometimes in ARM instructions that need to avoid using + // certain registers. Just treat it as GPR here. + if (RC == ARM::tGPRRegisterClass) + RC = ARM::GPRRegisterClass; + if (RC == ARM::GPRRegisterClass) { AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::LDR), DestReg) .addFrameIndex(FI).addReg(0).addImm(0).addMemOperand(MMO)); From sabre at nondot.org Tue Feb 16 16:13:59 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 22:13:59 -0000 Subject: [llvm-commits] [llvm] r96404 - /llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll Message-ID: <201002162214.o1GME6dG012131@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 16:13:43 2010 New Revision: 96404 URL: http://llvm.org/viewvc/llvm-project?rev=96404&view=rev Log: filecheckize Modified: llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll Modified: llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll?rev=96404&r1=96403&r2=96404&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll Tue Feb 16 16:13:43 2010 @@ -1,6 +1,4 @@ -; RUN: llc < %s -march=x86 -mattr=+sse,+sse2 -o %t -; RUN: grep minss %t | grep CPI | count 2 -; RUN: grep CPI %t | not grep movss +; RUN: llc < %s -march=x86 -mattr=+sse,+sse2 | FileCheck %s target datalayout = "e-p:32:32" target triple = "i686-apple-darwin8.7.2" @@ -17,6 +15,10 @@ %tmp.upgrd.1 = tail call i32 @llvm.x86.sse.cvttss2si( <4 x float> %tmp59 ) ; [#uses=1] %tmp69 = trunc i32 %tmp.upgrd.1 to i16 ; [#uses=1] ret i16 %tmp69 +; CHECK: test1: +; CHECK: subss LCPI1_ +; CHECK: mulss LCPI1_ +; CHECK: minss LCPI1_ } define i16 @test2(float %f) nounwind { @@ -28,6 +30,10 @@ %tmp = tail call i32 @llvm.x86.sse.cvttss2si( <4 x float> %tmp59 ) ; [#uses=1] %tmp69 = trunc i32 %tmp to i16 ; [#uses=1] ret i16 %tmp69 +; CHECK: test2: +; CHECK: addss LCPI2_ +; CHECK: mulss LCPI2_ +; CHECK: minss LCPI2_ } declare <4 x float> @llvm.x86.sse.sub.ss(<4 x float>, <4 x float>) From dag at cray.com Tue Feb 16 16:20:10 2010 From: dag at cray.com (David Greene) Date: Tue, 16 Feb 2010 16:20:10 -0600 Subject: [llvm-commits] [llvm] r96282 - in /llvm/trunk: lib/VMCore/Verifier.cpp unittests/VMCore/VerifierTest.cpp In-Reply-To: <89F93CB3-D858-4F68-97B6-11B7E4F47FC2@apple.com> References: <201002152209.o1FM99a1022937@zion.cs.uiuc.edu> <201002161523.09821.dag@cray.com> <89F93CB3-D858-4F68-97B6-11B7E4F47FC2@apple.com> Message-ID: <201002161620.11091.dag@cray.com> On Tuesday 16 February 2010 15:53:09 Chris Lattner wrote: > > On the other hand, tests like this encourage people to think more about > > API changes and what is really necessary. I don't see that as a bad > > thing. It won't prevent changes but might encourage people to think more > > about what they're doing and/or provide backward-compatibility if > > appropriate. > > I completely disagree, we are not interesting in avoiding api changes > because of inconvenience. That's not what I'm saying. I'm saying that when changes require some effort to implement people tend to think a bit more about long-term needs. -Dave From dalej at apple.com Tue Feb 16 16:31:36 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Feb 2010 22:31:36 -0000 Subject: [llvm-commits] [llvm] r96407 - in /llvm/trunk/test/CodeGen/PowerPC: 2007-04-30-InlineAsmEarlyClobber.ll 2009-08-17-inline-asm-addr-mode-breakage.ll LargeAbsoluteAddr.ll indirectbr.ll Message-ID: <201002162231.o1GMVcbC013138@zion.cs.uiuc.edu> Author: johannes Date: Tue Feb 16 16:31:31 2010 New Revision: 96407 URL: http://llvm.org/viewvc/llvm-project?rev=96407&view=rev Log: Adjust register numbers in tests to compensate for the new lack of R2. Modified: llvm/trunk/test/CodeGen/PowerPC/2007-04-30-InlineAsmEarlyClobber.ll llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll llvm/trunk/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Modified: llvm/trunk/test/CodeGen/PowerPC/2007-04-30-InlineAsmEarlyClobber.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2007-04-30-InlineAsmEarlyClobber.ll?rev=96407&r1=96406&r2=96407&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2007-04-30-InlineAsmEarlyClobber.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/2007-04-30-InlineAsmEarlyClobber.ll Tue Feb 16 16:31:31 2010 @@ -1,6 +1,6 @@ ; RUN: llc < %s | grep {subfc r3,r5,r4} -; RUN: llc < %s | grep {subfze r4,r2} -; RUN: llc < %s -regalloc=local | grep {subfc r2,r5,r4} +; RUN: llc < %s | grep {subfze r4,r6} +; RUN: llc < %s -regalloc=local | grep {subfc r6,r5,r4} ; RUN: llc < %s -regalloc=local | grep {subfze r3,r3} ; The first argument of subfc must not be the same as any other register. Modified: llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll?rev=96407&r1=96406&r2=96407&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll Tue Feb 16 16:31:31 2010 @@ -10,8 +10,8 @@ define void @foo(i32 %y) nounwind ssp { entry: ; CHECK: foo -; CHECK: add r2 -; CHECK: 0(r2) +; CHECK: add r4 +; CHECK: 0(r4) %y_addr = alloca i32 ; [#uses=2] %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] store i32 %y, i32* %y_addr Modified: llvm/trunk/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll?rev=96407&r1=96406&r2=96407&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll Tue Feb 16 16:31:31 2010 @@ -1,9 +1,9 @@ ; RUN: llc < %s -march=ppc32 -mtriple=powerpc-apple-darwin | \ -; RUN: grep {stw r3, 32751} +; RUN: grep {stw r4, 32751} ; RUN: llc < %s -march=ppc64 -mtriple=powerpc-apple-darwin | \ -; RUN: grep {stw r3, 32751} +; RUN: grep {stw r4, 32751} ; RUN: llc < %s -march=ppc64 -mtriple=powerpc-apple-darwin | \ -; RUN: grep {std r2, 9024} +; RUN: grep {std r3, 9024} define void @test() { store i32 0, i32* inttoptr (i64 48725999 to i32*) Modified: llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll?rev=96407&r1=96406&r2=96407&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/indirectbr.ll Tue Feb 16 16:31:31 2010 @@ -43,13 +43,13 @@ L1: ; preds = %L2, %bb2 %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; [#uses=1] -; PIC: addis r4, r2, ha16(L_BA4__foo_L5-"L1$pb") -; PIC: li r5, lo16(L_BA4__foo_L5-"L1$pb") -; PIC: add r4, r4, r5 -; PIC: stw r4 -; STATIC: li r2, lo16(L_BA4__foo_L5) -; STATIC: addis r2, r2, ha16(L_BA4__foo_L5) -; STATIC: stw r2 +; PIC: addis r5, r4, ha16(L_BA4__foo_L5-"L1$pb") +; PIC: li r6, lo16(L_BA4__foo_L5-"L1$pb") +; PIC: add r5, r5, r6 +; PIC: stw r5 +; STATIC: li r4, lo16(L_BA4__foo_L5) +; STATIC: addis r4, r4, ha16(L_BA4__foo_L5) +; STATIC: stw r4 store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 } From sabre at nondot.org Tue Feb 16 16:35:08 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 22:35:08 -0000 Subject: [llvm-commits] [llvm] r96408 - in /llvm/trunk: lib/Target/X86/X86ISelDAGToDAG.cpp test/CodeGen/X86/vec_ss_load_fold.ll utils/TableGen/DAGISelEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002162235.o1GMZANm013299@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 16:35:06 2010 New Revision: 96408 URL: http://llvm.org/viewvc/llvm-project?rev=96408&view=rev Log: fix rdar://7653908, a crash on a case where we would fold a load into a roundss intrinsic, producing a cyclic dag. The root cause of this is badness handling ComplexPattern nodes in the old dagisel that I noticed through inspection. Eliminate a copy of the of the code that handled ComplexPatterns by making EmitChildMatchCode call into EmitMatchCode. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=96408&r1=96407&r2=96408&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Tue Feb 16 16:35:06 2010 @@ -209,8 +209,8 @@ SDValue &Scale, SDValue &Index, SDValue &Disp); bool SelectTLSADDRAddr(SDNode *Op, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp); - bool SelectScalarSSELoad(SDNode *Op, SDValue Pred, - SDValue N, SDValue &Base, SDValue &Scale, + bool SelectScalarSSELoad(SDNode *Root, SDValue N, + SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, SDValue &Segment, SDValue &InChain, SDValue &OutChain); @@ -1317,7 +1317,7 @@ /// SelectScalarSSELoad - Match a scalar SSE load. In particular, we want to /// match a load whose top elements are either undef or zeros. The load flavor /// is derived from the type of N, which is either v4f32 or v2f64. -bool X86DAGToDAGISel::SelectScalarSSELoad(SDNode *Op, SDValue Pred, +bool X86DAGToDAGISel::SelectScalarSSELoad(SDNode *Root, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, SDValue &Segment, @@ -1327,10 +1327,10 @@ InChain = N.getOperand(0).getValue(1); if (ISD::isNON_EXTLoad(InChain.getNode()) && InChain.getValue(0).hasOneUse() && - IsProfitableToFold(N, Pred.getNode(), Op) && - IsLegalToFold(N, Pred.getNode(), Op)) { + IsProfitableToFold(N.getOperand(0), InChain.getNode(), Root) && + IsLegalToFold(N.getOperand(0), N.getNode(), Root)) { LoadSDNode *LD = cast(InChain); - if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, Disp, Segment)) + if (!SelectAddr(Root, LD->getBasePtr(), Base, Scale, Index, Disp,Segment)) return false; OutChain = LD->getChain(); return true; @@ -1344,10 +1344,12 @@ N.getOperand(0).getOpcode() == ISD::SCALAR_TO_VECTOR && N.getOperand(0).getNode()->hasOneUse() && ISD::isNON_EXTLoad(N.getOperand(0).getOperand(0).getNode()) && - N.getOperand(0).getOperand(0).hasOneUse()) { + N.getOperand(0).getOperand(0).hasOneUse() && + IsProfitableToFold(N.getOperand(0), N.getNode(), Root) && + IsLegalToFold(N.getOperand(0), N.getNode(), Root)) { // Okay, this is a zero extending load. Fold it. LoadSDNode *LD = cast(N.getOperand(0).getOperand(0)); - if (!SelectAddr(Op, LD->getBasePtr(), Base, Scale, Index, Disp, Segment)) + if (!SelectAddr(Root, LD->getBasePtr(), Base, Scale, Index, Disp, Segment)) return false; OutChain = LD->getChain(); InChain = SDValue(LD, 1); @@ -1424,7 +1426,6 @@ bool X86DAGToDAGISel::SelectTLSADDRAddr(SDNode *Op, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp) { - assert(Op->getOpcode() == X86ISD::TLSADDR); assert(N.getOpcode() == ISD::TargetGlobalTLSAddress); const GlobalAddressSDNode *GA = cast(N); Modified: llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll?rev=96408&r1=96407&r2=96408&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll Tue Feb 16 16:35:06 2010 @@ -45,3 +45,28 @@ declare <4 x float> @llvm.x86.sse.max.ss(<4 x float>, <4 x float>) declare i32 @llvm.x86.sse.cvttss2si(<4 x float>) + + +declare <4 x float> @llvm.x86.sse41.round.ss(<4 x float>, <4 x float>, i32) +declare <4 x float> @f() + +define <4 x float> @test3(<4 x float> %A, float *%b, i32 %C) nounwind { + %a = load float *%b + %B = insertelement <4 x float> undef, float %a, i32 0 + %X = call <4 x float> @llvm.x86.sse41.round.ss(<4 x float> %A, <4 x float> %B, i32 4) + ret <4 x float> %X +; CHECK: test3: +; CHECK: roundss $4, (%eax), %xmm0 +} + +define <4 x float> @test4(<4 x float> %A, float *%b, i32 %C) nounwind { + %a = load float *%b + %B = insertelement <4 x float> undef, float %a, i32 0 + %q = call <4 x float> @f() + %X = call <4 x float> @llvm.x86.sse41.round.ss(<4 x float> %q, <4 x float> %B, i32 4) + ret <4 x float> %X +; CHECK: test4: +; CHECK: movss (%eax), %xmm +; CHECK: call +; CHECK: roundss $4, %xmm{{.*}}, %xmm0 +} \ No newline at end of file Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96408&r1=96407&r2=96408&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 16:35:06 2010 @@ -510,7 +510,6 @@ const std::string &RootName, const std::string &ChainSuffix, bool &FoundChain) { - // Save loads/stores matched by a pattern. if (!N->isLeaf() && N->getName().empty()) { if (N->NodeHasProperty(SDNPMemOperand, CGP)) @@ -573,7 +572,7 @@ // use. If the node has multiple uses and the pattern has a load as // an operand, then we can't fold the load. emitCheck(getValueName(RootName) + ".hasOneUse()"); - } else { + } else if (!N->isLeaf()) { // ComplexPatterns do their own legality check. // If the immediate use can somehow reach this node through another // path, then can't fold it either or it will create a cycle. // e.g. In the following diagram, XX can reach ld through YY. If @@ -627,8 +626,11 @@ } else FoundChain = true; ChainName = "Chain" + ChainSuffix; - emitInit("SDValue " + ChainName + " = " + getNodeName(RootName) + - "->getOperand(0);"); + + if (!N->getComplexPatternInfo(CGP) || + isRoot) + emitInit("SDValue " + ChainName + " = " + getNodeName(RootName) + + "->getOperand(0);"); } } @@ -686,7 +688,7 @@ // Handle cases when root is a complex pattern. const ComplexPattern *CP; - if (isRoot && N->isLeaf() && (CP = N->getComplexPatternInfo(CGP))) { + if (N->isLeaf() && (CP = N->getComplexPatternInfo(CGP))) { std::string Fn = CP->getSelectFunc(); unsigned NumOps = CP->getNumOperands(); for (unsigned i = 0; i < NumOps; ++i) { @@ -700,9 +702,8 @@ emitCode("SDValue Chain" + ChainSuffix + ";"); } - std::string Code = Fn + "(" + - getNodeName(RootName) + ", " + - getValueName(RootName); + std::string Code = Fn + "(N, "; // always pass in the root. + Code += getValueName(RootName); for (unsigned i = 0; i < NumOps; i++) Code += ", CPTmp" + RootName + "_" + utostr(i); if (CP->hasProperty(SDNPHasChain)) { @@ -736,6 +737,24 @@ FoldedFlag = std::make_pair(getValueName(RootName), CInfo.getNumResults() + (unsigned)HasChain); } + } else if (const ComplexPattern *CP = Child->getComplexPatternInfo(CGP)) { + if (CP->getSelectFunc() == "SelectScalarSSELoad") + errs() << "FOUND IT\n"; + EmitMatchCode(Child, Parent, RootName, ChainSuffix, FoundChain); + bool HasChain = false; + + if (Child->NodeHasProperty(SDNPHasChain, CGP)) { + HasChain = true; + const SDNodeInfo &PInfo = CGP.getSDNodeInfo(Parent->getOperator()); + FoldedChains.push_back(std::make_pair("CPInChain", + PInfo.getNumResults())); + } + if (Child->NodeHasProperty(SDNPOutFlag, CGP)) { + assert(FoldedFlag.first == "" && FoldedFlag.second == 0 && + "Pattern folded multiple nodes which produce flags?"); + FoldedFlag = std::make_pair(getValueName(RootName), + CP->getNumOperands() + (unsigned)HasChain); + } } else { // If this child has a name associated with it, capture it in VarMap. If // we already saw this in the pattern, emit code to verify dagness. @@ -762,37 +781,6 @@ // Handle register references. Nothing to do here. } else if (LeafRec->isSubClassOf("Register")) { // Handle register references. - } else if (LeafRec->isSubClassOf("ComplexPattern")) { - // Handle complex pattern. - const ComplexPattern *CP = Child->getComplexPatternInfo(CGP); - std::string Fn = CP->getSelectFunc(); - unsigned NumOps = CP->getNumOperands(); - for (unsigned i = 0; i < NumOps; ++i) { - emitDecl("CPTmp" + RootName + "_" + utostr(i)); - emitCode("SDValue CPTmp" + RootName + "_" + utostr(i) + ";"); - } - if (CP->hasProperty(SDNPHasChain)) { - const SDNodeInfo &PInfo = CGP.getSDNodeInfo(Parent->getOperator()); - FoldedChains.push_back(std::make_pair("CPInChain", - PInfo.getNumResults())); - ChainName = "Chain" + ChainSuffix; - emitDecl("CPInChain"); - emitDecl(ChainName); - emitCode("SDValue CPInChain;"); - emitCode("SDValue " + ChainName + ";"); - } - - std::string Code = Fn + "(N, "; - if (CP->hasProperty(SDNPHasChain)) { - std::string ParentName(RootName.begin(), RootName.end()-1); - Code += getValueName(ParentName) + ", "; - } - Code += getValueName(RootName); - for (unsigned i = 0; i < NumOps; i++) - Code += ", CPTmp" + RootName + "_" + utostr(i); - if (CP->hasProperty(SDNPHasChain)) - Code += ", CPInChain, Chain" + ChainSuffix; - emitCheck(Code + ")"); } else if (LeafRec->getName() == "srcvalue") { // Place holder for SRCVALUE nodes. Nothing to do here. } else if (LeafRec->isSubClassOf("ValueType")) { Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96408&r1=96407&r2=96408&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 16:35:06 2010 @@ -212,7 +212,6 @@ // const TreePatternNode *Root = Pattern.getSrcPattern(); if (N != Root) { // Not the root of the pattern. - // If there is a node between the root and this node, then we definitely // need to emit the check. bool NeedCheck = !Root->hasChild(N); From sabre at nondot.org Tue Feb 16 16:38:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 22:38:42 -0000 Subject: [llvm-commits] [llvm] r96409 - /llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002162238.o1GMcgQe013480@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 16:38:31 2010 New Revision: 96409 URL: http://llvm.org/viewvc/llvm-project?rev=96409&view=rev Log: fix indentation Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96409&r1=96408&r2=96409&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 16:38:31 2010 @@ -737,9 +737,10 @@ FoldedFlag = std::make_pair(getValueName(RootName), CInfo.getNumResults() + (unsigned)HasChain); } - } else if (const ComplexPattern *CP = Child->getComplexPatternInfo(CGP)) { - if (CP->getSelectFunc() == "SelectScalarSSELoad") - errs() << "FOUND IT\n"; + return; + } + + if (const ComplexPattern *CP = Child->getComplexPatternInfo(CGP)) { EmitMatchCode(Child, Parent, RootName, ChainSuffix, FoundChain); bool HasChain = false; @@ -755,73 +756,76 @@ FoldedFlag = std::make_pair(getValueName(RootName), CP->getNumOperands() + (unsigned)HasChain); } - } else { - // If this child has a name associated with it, capture it in VarMap. If - // we already saw this in the pattern, emit code to verify dagness. - if (!Child->getName().empty()) { - std::string &VarMapEntry = VariableMap[Child->getName()]; - if (VarMapEntry.empty()) { - VarMapEntry = getValueName(RootName); - } else { - // If we get here, this is a second reference to a specific name. - // Since we already have checked that the first reference is valid, - // we don't have to recursively match it, just check that it's the - // same as the previously named thing. - emitCheck(VarMapEntry + " == " + getValueName(RootName)); - Duplicates.insert(getValueName(RootName)); - return; - } + return; + } + + // If this child has a name associated with it, capture it in VarMap. If + // we already saw this in the pattern, emit code to verify dagness. + if (!Child->getName().empty()) { + std::string &VarMapEntry = VariableMap[Child->getName()]; + if (VarMapEntry.empty()) { + VarMapEntry = getValueName(RootName); + } else { + // If we get here, this is a second reference to a specific name. + // Since we already have checked that the first reference is valid, + // we don't have to recursively match it, just check that it's the + // same as the previously named thing. + emitCheck(VarMapEntry + " == " + getValueName(RootName)); + Duplicates.insert(getValueName(RootName)); + return; } - - // Handle leaves of various types. - if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { - Record *LeafRec = DI->getDef(); - if (LeafRec->isSubClassOf("RegisterClass") || - LeafRec->isSubClassOf("PointerLikeRegClass")) { - // Handle register references. Nothing to do here. - } else if (LeafRec->isSubClassOf("Register")) { - // Handle register references. - } else if (LeafRec->getName() == "srcvalue") { - // Place holder for SRCVALUE nodes. Nothing to do here. - } else if (LeafRec->isSubClassOf("ValueType")) { - // Make sure this is the specified value type. - emitCheck("cast(" + getNodeName(RootName) + - ")->getVT() == MVT::" + LeafRec->getName()); - } else if (LeafRec->isSubClassOf("CondCode")) { - // Make sure this is the specified cond code. - emitCheck("cast(" + getNodeName(RootName) + - ")->get() == ISD::" + LeafRec->getName()); - } else { -#ifndef NDEBUG - Child->dump(); - errs() << " "; -#endif - assert(0 && "Unknown leaf type!"); - } - - // If there are node predicates for this, emit the calls. - for (unsigned i = 0, e = Child->getPredicateFns().size(); i != e; ++i) - emitCheck(Child->getPredicateFns()[i] + "(" + getNodeName(RootName) + - ")"); - } else if (IntInit *II = - dynamic_cast(Child->getLeafValue())) { - unsigned NTmp = TmpNo++; - emitCode("ConstantSDNode *Tmp"+ utostr(NTmp) + - " = dyn_cast("+ - getNodeName(RootName) + ");"); - emitCheck("Tmp" + utostr(NTmp)); - unsigned CTmp = TmpNo++; - emitCode("int64_t CN"+ utostr(CTmp) + - " = Tmp" + utostr(NTmp) + "->getSExtValue();"); - emitCheck("CN" + utostr(CTmp) + " == " - "INT64_C(" +itostr(II->getValue()) + ")"); + } + + // Handle leaves of various types. + if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { + Record *LeafRec = DI->getDef(); + if (LeafRec->isSubClassOf("RegisterClass") || + LeafRec->isSubClassOf("PointerLikeRegClass")) { + // Handle register references. Nothing to do here. + } else if (LeafRec->isSubClassOf("Register")) { + // Handle register references. + } else if (LeafRec->getName() == "srcvalue") { + // Place holder for SRCVALUE nodes. Nothing to do here. + } else if (LeafRec->isSubClassOf("ValueType")) { + // Make sure this is the specified value type. + emitCheck("cast(" + getNodeName(RootName) + + ")->getVT() == MVT::" + LeafRec->getName()); + } else if (LeafRec->isSubClassOf("CondCode")) { + // Make sure this is the specified cond code. + emitCheck("cast(" + getNodeName(RootName) + + ")->get() == ISD::" + LeafRec->getName()); } else { #ifndef NDEBUG Child->dump(); + errs() << " "; #endif assert(0 && "Unknown leaf type!"); } + + // If there are node predicates for this, emit the calls. + for (unsigned i = 0, e = Child->getPredicateFns().size(); i != e; ++i) + emitCheck(Child->getPredicateFns()[i] + "(" + getNodeName(RootName) + + ")"); + return; + } + + if (IntInit *II = dynamic_cast(Child->getLeafValue())) { + unsigned NTmp = TmpNo++; + emitCode("ConstantSDNode *Tmp"+ utostr(NTmp) + + " = dyn_cast("+ + getNodeName(RootName) + ");"); + emitCheck("Tmp" + utostr(NTmp)); + unsigned CTmp = TmpNo++; + emitCode("int64_t CN"+ utostr(CTmp) + + " = Tmp" + utostr(NTmp) + "->getSExtValue();"); + emitCheck("CN" + utostr(CTmp) + " == " + "INT64_C(" +itostr(II->getValue()) + ")"); + return; } +#ifndef NDEBUG + Child->dump(); +#endif + assert(0 && "Unknown leaf type!"); } /// EmitResultCode - Emit the action for a pattern. Now that it has matched From isanbard at gmail.com Tue Feb 16 16:47:39 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Feb 2010 22:47:39 -0000 Subject: [llvm-commits] [llvm] r96410 - /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Message-ID: <201002162247.o1GMlfSn013965@zion.cs.uiuc.edu> Author: void Date: Tue Feb 16 16:47:14 2010 New Revision: 96410 URL: http://llvm.org/viewvc/llvm-project?rev=96410&view=rev Log: Make error statement more personal. Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=96410&r1=96409&r2=96410&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Tue Feb 16 16:47:14 2010 @@ -307,7 +307,7 @@ switch (Encoding & 0xF0) { default: - llvm_report_error("Do not support this DWARF encoding yet!"); + llvm_report_error("We do not support this DWARF encoding yet!"); break; case dwarf::DW_EH_PE_absptr: // Do nothing special From wendling at apple.com Tue Feb 16 17:11:20 2010 From: wendling at apple.com (Bill Wendling) Date: Tue, 16 Feb 2010 15:11:20 -0800 Subject: [llvm-commits] [llvm] r96386 - in /llvm/trunk: docs/LangRef.html lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-02-11-NonTemporal.ll In-Reply-To: <201002162050.o1GKoM15007715@zion.cs.uiuc.edu> References: <201002162050.o1GKoM15007715@zion.cs.uiuc.edu> Message-ID: <7FD1CFB1-F971-406C-986C-755B09EBB98B@apple.com> Hi David, On Feb 16, 2010, at 12:50 PM, David Greene wrote: > Modified: llvm/trunk/docs/LangRef.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=96386&r1=96385&r2=96386&view=diff > > ============================================================================== > --- llvm/trunk/docs/LangRef.html (original) > +++ llvm/trunk/docs/LangRef.html Tue Feb 16 14:50:18 2010 > @@ -4098,6 +4099,14 @@ > alignment results in an undefined behavior. Underestimating the alignment may > produce less efficient code. An alignment of 1 is always safe.

    > > +

    The optional !nontemporal metadata must reference a single metatadata Please put "!nontemporal" between tags. > + name corresponding to a metadata node with one i32 entry of Please use >/< for the "". Should it be within tags as well? > + value 1. The existance of the !nontemporal metatadata on the > + instruction tells the optimizer and code generator that this load is > + not expected to be reused in the cache. The code generator may > + select special instructions to save cache bandwidth, such as the > + MOVNT intruction on x86.

    for MOVNT please. > @@ -4150,6 +4159,15 @@ > alignment results in an undefined behavior. Underestimating the alignment may > produce less efficient code. An alignment of 1 is always safe.

    > > +

    The optional !nontemporal metadata must reference a single metatadata > + name corresponding to a metadata node with one i32 entry of > + value 1. The existance of the !nontemporal metatadata on the > + instruction tells the optimizer and code generator that this load is > + not expected to be reused in the cache. The code generator may > + select special instructions to save cache bandwidth, such as the > + MOVNT intruction on x86.

    > + Ditto as above. -bw From sabre at nondot.org Tue Feb 16 17:14:12 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 23:14:12 -0000 Subject: [llvm-commits] [llvm] r96411 - /llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002162314.o1GNEICx015436@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 17:13:59 2010 New Revision: 96411 URL: http://llvm.org/viewvc/llvm-project?rev=96411&view=rev Log: clean up some code, eliminate NodeIsComplexPattern, which does the same thing as getComplexPatternInfo. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96411&r1=96410&r2=96411&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 17:13:59 2010 @@ -47,16 +47,6 @@ return S; } -/// NodeIsComplexPattern - return true if N is a leaf node and a subclass of -/// ComplexPattern. -static bool NodeIsComplexPattern(TreePatternNode *N) { - return (N->isLeaf() && - dynamic_cast(N->getLeafValue()) && - static_cast(N->getLeafValue())->getDef()-> - isSubClassOf("ComplexPattern")); -} - - /// getPatternSize - Return the 'size' of this pattern. We want to match large /// patterns before small ones. This is used to determine the size of a /// pattern. @@ -96,7 +86,7 @@ else if (Child->isLeaf()) { if (dynamic_cast(Child->getLeafValue())) Size += 5; // Matches a ConstantSDNode (+3) and a specific value (+2). - else if (NodeIsComplexPattern(Child)) + else if (Child->getComplexPatternInfo(CGP)) Size += getPatternSize(Child, CGP); else if (!Child->getPredicateFns().empty()) ++Size; @@ -530,10 +520,9 @@ ")->getSExtValue() == INT64_C(" + itostr(II->getValue()) + ")"); return; - } else if (!NodeIsComplexPattern(N)) { - assert(0 && "Cannot match this as a leaf value!"); - abort(); } + assert(N->getComplexPatternInfo(CGP) != 0 && + "Cannot match this as a leaf value!"); } // If this node has a name associated with it, capture it in VariableMap. If @@ -2014,11 +2003,9 @@ else Matcher = new PushMatcherNode(N, Matcher); } - - + + // OptimizeMatcher(Matcher); EmitMatcherTable(Matcher, OS); - - //Matcher->dump(); delete Matcher; #endif From sabre at nondot.org Tue Feb 16 17:16:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Feb 2010 23:16:42 -0000 Subject: [llvm-commits] [llvm] r96412 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002162316.o1GNGgSg015583@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 17:16:25 2010 New Revision: 96412 URL: http://llvm.org/viewvc/llvm-project?rev=96412&view=rev Log: complex patterns don't get 'record' nodes, they implicitly record all their results. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96412&r1=96411&r2=96412&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 17:16:25 2010 @@ -137,6 +137,11 @@ return AddMatcherNode(new CheckCondCodeMatcherNode(LeafRec->getName())); if (LeafRec->isSubClassOf("ComplexPattern")) { + if (!N->getName().empty()) { + errs() << "We expect complex pattern uses to have names: " << *N << "\n"; + exit(1); + } + // Handle complex pattern. const ComplexPattern &CP = CGP.getComplexPattern(LeafRec); return AddMatcherNode(new CheckComplexPatMatcherNode(CP)); @@ -236,6 +241,8 @@ AddMatcherNode(new CheckFoldableChainNodeMatcherNode()); } } + + // FIXME: Need to generate IsChainCompatible checks. for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { // Get the code suitable for matching this child. Move to the child, check @@ -265,7 +272,19 @@ unsigned &VarMapEntry = VariableMap[N->getName()]; if (VarMapEntry == 0) { VarMapEntry = ++NextRecordedOperandNo; - AddMatcherNode(new RecordMatcherNode()); + + // If this is a complex pattern, the match operation for it will + // implicitly record all of the outputs of it (which may be more than + // one). + if (const ComplexPattern *AM = N->getComplexPatternInfo(CGP)) { + // Record the right number of operands. + // FIXME: Does this include chain? + VarMapEntry += AM->getNumOperands()-1; + } else { + // If it is a normal named node, we must emit a 'Record' opcode. + AddMatcherNode(new RecordMatcherNode()); + } + } else { // If we get here, this is a second reference to a specific name. Since // we already have checked that the first reference is valid, we don't From dalej at apple.com Tue Feb 16 17:25:37 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Feb 2010 23:25:37 -0000 Subject: [llvm-commits] [llvm] r96413 - /llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll Message-ID: <201002162325.o1GNPexS016084@zion.cs.uiuc.edu> Author: johannes Date: Tue Feb 16 17:25:23 2010 New Revision: 96413 URL: http://llvm.org/viewvc/llvm-project?rev=96413&view=rev Log: Make g5 target explicit; scheduling affects register choice. Modified: llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll Modified: llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll?rev=96413&r1=96412&r2=96413&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/2009-08-17-inline-asm-addr-mode-breakage.ll Tue Feb 16 17:25:23 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=ppc32 | FileCheck %s +; RUN: llc < %s -march=ppc32 -mtriple=powerpc-apple-darwin10 -mcpu=g5 | FileCheck %s ; ModuleID = '' target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f128:64:128" target triple = "powerpc-apple-darwin10.0" From sabre at nondot.org Tue Feb 16 18:11:33 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 00:11:33 -0000 Subject: [llvm-commits] [llvm] r96416 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002170011.o1H0BYY9018313@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 18:11:30 2010 New Revision: 96416 URL: http://llvm.org/viewvc/llvm-project?rev=96416&view=rev Log: fix inverted condition. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96416&r1=96415&r2=96416&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 18:11:30 2010 @@ -137,7 +137,9 @@ return AddMatcherNode(new CheckCondCodeMatcherNode(LeafRec->getName())); if (LeafRec->isSubClassOf("ComplexPattern")) { - if (!N->getName().empty()) { + // We can't model ComplexPattern uses that don't have their name taken yet. + // The OPC_CheckComplexPattern operation implicitly records the results. + if (N->getName().empty()) { errs() << "We expect complex pattern uses to have names: " << *N << "\n"; exit(1); } From sabre at nondot.org Tue Feb 16 18:29:06 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 00:29:06 -0000 Subject: [llvm-commits] [llvm] r96417 - /llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll Message-ID: <201002170029.o1H0T6kh019218@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 18:29:06 2010 New Revision: 96417 URL: http://llvm.org/viewvc/llvm-project?rev=96417&view=rev Log: roundss is an sse 4 thing, fix the test on non-sse41 builders like llvm-gcc-x86_64-darwin10-selfhost Modified: llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll Modified: llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll?rev=96417&r1=96416&r2=96417&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_ss_load_fold.ll Tue Feb 16 18:29:06 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 -mattr=+sse,+sse2 | FileCheck %s +; RUN: llc < %s -march=x86 -mattr=+sse,+sse2,+sse41 | FileCheck %s target datalayout = "e-p:32:32" target triple = "i686-apple-darwin8.7.2" From bob.wilson at apple.com Tue Feb 16 18:31:29 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Feb 2010 00:31:29 -0000 Subject: [llvm-commits] [llvm] r96418 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <201002170031.o1H0VTaq019315@zion.cs.uiuc.edu> Author: bwilson Date: Tue Feb 16 18:31:29 2010 New Revision: 96418 URL: http://llvm.org/viewvc/llvm-project?rev=96418&view=rev Log: Wrap lines to 80 columns and generally try to clean up whitespace and indentation. No functional changes. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=96418&r1=96417&r2=96418&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Tue Feb 16 18:31:29 2010 @@ -83,7 +83,8 @@ def NEONvrev16 : SDNode<"ARMISD::VREV16", SDTARMVSHUF>; def SDTARMVSHUF2 : SDTypeProfile<2, 2, [SDTCisVec<0>, SDTCisSameAs<0, 1>, - SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>]>; + SDTCisSameAs<0, 2>, + SDTCisSameAs<0, 3>]>; def NEONzip : SDNode<"ARMISD::VZIP", SDTARMVSHUF2>; def NEONuzp : SDNode<"ARMISD::VUZP", SDTARMVSHUF2>; def NEONtrn : SDNode<"ARMISD::VTRN", SDTARMVSHUF2>; @@ -123,9 +124,7 @@ let mayLoad = 1, hasExtraDefRegAllocReq = 1 in { def VLDMD : NI<(outs), (ins addrmode_neonldstm:$addr, reglist:$dst1, variable_ops), - IIC_fpLoadm, - "vldm", "${addr:submode} ${addr:base}, $dst1", - []> { + IIC_fpLoadm, "vldm", "${addr:submode} ${addr:base}, $dst1", []> { let Inst{27-25} = 0b110; let Inst{20} = 1; let Inst{11-9} = 0b101; @@ -133,9 +132,7 @@ def VLDMS : NI<(outs), (ins addrmode_neonldstm:$addr, reglist:$dst1, variable_ops), - IIC_fpLoadm, - "vldm", "${addr:submode} ${addr:base}, $dst1", - []> { + IIC_fpLoadm, "vldm", "${addr:submode} ${addr:base}, $dst1", []> { let Inst{27-25} = 0b110; let Inst{20} = 1; let Inst{11-9} = 0b101; @@ -144,10 +141,9 @@ */ // Use vldmia to load a Q register as a D register pair. -def VLDRQ : NI4<(outs QPR:$dst), (ins addrmode4:$addr), - IIC_fpLoadm, - "vldmia", "$addr, ${dst:dregpair}", - [(set QPR:$dst, (v2f64 (load addrmode4:$addr)))]> { +def VLDRQ : NI4<(outs QPR:$dst), (ins addrmode4:$addr), IIC_fpLoadm, + "vldmia", "$addr, ${dst:dregpair}", + [(set QPR:$dst, (v2f64 (load addrmode4:$addr)))]> { let Inst{27-25} = 0b110; let Inst{24} = 0; // P bit let Inst{23} = 1; // U bit @@ -156,10 +152,9 @@ } // Use vstmia to store a Q register as a D register pair. -def VSTRQ : NI4<(outs), (ins QPR:$src, addrmode4:$addr), - IIC_fpStorem, - "vstmia", "$addr, ${src:dregpair}", - [(store (v2f64 QPR:$src), addrmode4:$addr)]> { +def VSTRQ : NI4<(outs), (ins QPR:$src, addrmode4:$addr), IIC_fpStorem, + "vstmia", "$addr, ${src:dregpair}", + [(store (v2f64 QPR:$src), addrmode4:$addr)]> { let Inst{27-25} = 0b110; let Inst{24} = 0; // P bit let Inst{23} = 1; // U bit @@ -285,105 +280,64 @@ class VLD2LN op11_8, string OpcodeStr, string Dt> : NLdSt<1,0b10,op11_8,{?,?,?,?}, (outs DPR:$dst1, DPR:$dst2), (ins addrmode6:$addr, DPR:$src1, DPR:$src2, nohash_imm:$lane), - IIC_VLD2, - OpcodeStr, Dt, "\\{$dst1[$lane], $dst2[$lane]\\}, $addr", + IIC_VLD2, OpcodeStr, Dt, "\\{$dst1[$lane], $dst2[$lane]\\}, $addr", "$src1 = $dst1, $src2 = $dst2", []>; // vld2 to single-spaced registers. def VLD2LNd8 : VLD2LN<0b0001, "vld2", "8">; -def VLD2LNd16 : VLD2LN<0b0101, "vld2", "16"> { - let Inst{5} = 0; -} -def VLD2LNd32 : VLD2LN<0b1001, "vld2", "32"> { - let Inst{6} = 0; -} +def VLD2LNd16 : VLD2LN<0b0101, "vld2", "16"> { let Inst{5} = 0; } +def VLD2LNd32 : VLD2LN<0b1001, "vld2", "32"> { let Inst{6} = 0; } // vld2 to double-spaced even registers. -def VLD2LNq16a: VLD2LN<0b0101, "vld2", "16"> { - let Inst{5} = 1; -} -def VLD2LNq32a: VLD2LN<0b1001, "vld2", "32"> { - let Inst{6} = 1; -} +def VLD2LNq16a: VLD2LN<0b0101, "vld2", "16"> { let Inst{5} = 1; } +def VLD2LNq32a: VLD2LN<0b1001, "vld2", "32"> { let Inst{6} = 1; } // vld2 to double-spaced odd registers. -def VLD2LNq16b: VLD2LN<0b0101, "vld2", "16"> { - let Inst{5} = 1; -} -def VLD2LNq32b: VLD2LN<0b1001, "vld2", "32"> { - let Inst{6} = 1; -} +def VLD2LNq16b: VLD2LN<0b0101, "vld2", "16"> { let Inst{5} = 1; } +def VLD2LNq32b: VLD2LN<0b1001, "vld2", "32"> { let Inst{6} = 1; } // VLD3LN : Vector Load (single 3-element structure to one lane) class VLD3LN op11_8, string OpcodeStr, string Dt> : NLdSt<1,0b10,op11_8,{?,?,?,?}, (outs DPR:$dst1, DPR:$dst2, DPR:$dst3), (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, - nohash_imm:$lane), IIC_VLD3, - OpcodeStr, Dt, + nohash_imm:$lane), IIC_VLD3, OpcodeStr, Dt, "\\{$dst1[$lane], $dst2[$lane], $dst3[$lane]\\}, $addr", "$src1 = $dst1, $src2 = $dst2, $src3 = $dst3", []>; // vld3 to single-spaced registers. -def VLD3LNd8 : VLD3LN<0b0010, "vld3", "8"> { - let Inst{4} = 0; -} -def VLD3LNd16 : VLD3LN<0b0110, "vld3", "16"> { - let Inst{5-4} = 0b00; -} -def VLD3LNd32 : VLD3LN<0b1010, "vld3", "32"> { - let Inst{6-4} = 0b000; -} +def VLD3LNd8 : VLD3LN<0b0010, "vld3", "8"> { let Inst{4} = 0; } +def VLD3LNd16 : VLD3LN<0b0110, "vld3", "16"> { let Inst{5-4} = 0b00; } +def VLD3LNd32 : VLD3LN<0b1010, "vld3", "32"> { let Inst{6-4} = 0b000; } // vld3 to double-spaced even registers. -def VLD3LNq16a: VLD3LN<0b0110, "vld3", "16"> { - let Inst{5-4} = 0b10; -} -def VLD3LNq32a: VLD3LN<0b1010, "vld3", "32"> { - let Inst{6-4} = 0b100; -} +def VLD3LNq16a: VLD3LN<0b0110, "vld3", "16"> { let Inst{5-4} = 0b10; } +def VLD3LNq32a: VLD3LN<0b1010, "vld3", "32"> { let Inst{6-4} = 0b100; } // vld3 to double-spaced odd registers. -def VLD3LNq16b: VLD3LN<0b0110, "vld3", "16"> { - let Inst{5-4} = 0b10; -} -def VLD3LNq32b: VLD3LN<0b1010, "vld3", "32"> { - let Inst{6-4} = 0b100; -} +def VLD3LNq16b: VLD3LN<0b0110, "vld3", "16"> { let Inst{5-4} = 0b10; } +def VLD3LNq32b: VLD3LN<0b1010, "vld3", "32"> { let Inst{6-4} = 0b100; } // VLD4LN : Vector Load (single 4-element structure to one lane) class VLD4LN op11_8, string OpcodeStr, string Dt> : NLdSt<1,0b10,op11_8,{?,?,?,?}, (outs DPR:$dst1, DPR:$dst2, DPR:$dst3, DPR:$dst4), (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4, - nohash_imm:$lane), IIC_VLD4, - OpcodeStr, Dt, + nohash_imm:$lane), IIC_VLD4, OpcodeStr, Dt, "\\{$dst1[$lane], $dst2[$lane], $dst3[$lane], $dst4[$lane]\\}, $addr", "$src1 = $dst1, $src2 = $dst2, $src3 = $dst3, $src4 = $dst4", []>; // vld4 to single-spaced registers. def VLD4LNd8 : VLD4LN<0b0011, "vld4", "8">; -def VLD4LNd16 : VLD4LN<0b0111, "vld4", "16"> { - let Inst{5} = 0; -} -def VLD4LNd32 : VLD4LN<0b1011, "vld4", "32"> { - let Inst{6} = 0; -} +def VLD4LNd16 : VLD4LN<0b0111, "vld4", "16"> { let Inst{5} = 0; } +def VLD4LNd32 : VLD4LN<0b1011, "vld4", "32"> { let Inst{6} = 0; } // vld4 to double-spaced even registers. -def VLD4LNq16a: VLD4LN<0b0111, "vld4", "16"> { - let Inst{5} = 1; -} -def VLD4LNq32a: VLD4LN<0b1011, "vld4", "32"> { - let Inst{6} = 1; -} +def VLD4LNq16a: VLD4LN<0b0111, "vld4", "16"> { let Inst{5} = 1; } +def VLD4LNq32a: VLD4LN<0b1011, "vld4", "32"> { let Inst{6} = 1; } // vld4 to double-spaced odd registers. -def VLD4LNq16b: VLD4LN<0b0111, "vld4", "16"> { - let Inst{5} = 1; -} -def VLD4LNq32b: VLD4LN<0b1011, "vld4", "32"> { - let Inst{6} = 1; -} +def VLD4LNq16b: VLD4LN<0b0111, "vld4", "16"> { let Inst{5} = 1; } +def VLD4LNq32b: VLD4LN<0b1011, "vld4", "32"> { let Inst{6} = 1; } // VLD1DUP : Vector Load (single element to all lanes) // VLD2DUP : Vector Load (single 2-element structure to all lanes) @@ -428,8 +382,7 @@ class VST2Q op7_4, string OpcodeStr, string Dt> : NLdSt<0,0b00,0b0011,op7_4, (outs), (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4), - IIC_VST, - OpcodeStr, Dt, "\\{$src1, $src2, $src3, $src4\\}, $addr", + IIC_VST, OpcodeStr, Dt, "\\{$src1, $src2, $src3, $src4\\}, $addr", "", []>; def VST2d8 : VST2D<0b0000, "vst2", "8">; @@ -476,14 +429,12 @@ class VST4D op7_4, string OpcodeStr, string Dt> : NLdSt<0,0b00,0b0000,op7_4, (outs), (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4), - IIC_VST, - OpcodeStr, Dt, "\\{$src1, $src2, $src3, $src4\\}, $addr", + IIC_VST, OpcodeStr, Dt, "\\{$src1, $src2, $src3, $src4\\}, $addr", "", []>; class VST4WB op7_4, string OpcodeStr, string Dt> : NLdSt<0,0b00,0b0001,op7_4, (outs GPR:$wb), (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4), - IIC_VST, - OpcodeStr, Dt, "\\{$src1, $src2, $src3, $src4\\}, $addr", + IIC_VST, OpcodeStr, Dt, "\\{$src1, $src2, $src3, $src4\\}, $addr", "$addr.addr = $wb", []>; def VST4d8 : VST4D<0b0000, "vst4", "8">; @@ -511,104 +462,63 @@ // VST2LN : Vector Store (single 2-element structure from one lane) class VST2LN op11_8, string OpcodeStr, string Dt> : NLdSt<1,0b00,op11_8,{?,?,?,?}, (outs), - (ins addrmode6:$addr, DPR:$src1, DPR:$src2, nohash_imm:$lane), - IIC_VST, - OpcodeStr, Dt, "\\{$src1[$lane], $src2[$lane]\\}, $addr", - "", []>; + (ins addrmode6:$addr, DPR:$src1, DPR:$src2, nohash_imm:$lane), + IIC_VST, OpcodeStr, Dt, "\\{$src1[$lane], $src2[$lane]\\}, $addr", + "", []>; // vst2 to single-spaced registers. def VST2LNd8 : VST2LN<0b0001, "vst2", "8">; -def VST2LNd16 : VST2LN<0b0101, "vst2", "16"> { - let Inst{5} = 0; -} -def VST2LNd32 : VST2LN<0b1001, "vst2", "32"> { - let Inst{6} = 0; -} +def VST2LNd16 : VST2LN<0b0101, "vst2", "16"> { let Inst{5} = 0; } +def VST2LNd32 : VST2LN<0b1001, "vst2", "32"> { let Inst{6} = 0; } // vst2 to double-spaced even registers. -def VST2LNq16a: VST2LN<0b0101, "vst2", "16"> { - let Inst{5} = 1; -} -def VST2LNq32a: VST2LN<0b1001, "vst2", "32"> { - let Inst{6} = 1; -} +def VST2LNq16a: VST2LN<0b0101, "vst2", "16"> { let Inst{5} = 1; } +def VST2LNq32a: VST2LN<0b1001, "vst2", "32"> { let Inst{6} = 1; } // vst2 to double-spaced odd registers. -def VST2LNq16b: VST2LN<0b0101, "vst2", "16"> { - let Inst{5} = 1; -} -def VST2LNq32b: VST2LN<0b1001, "vst2", "32"> { - let Inst{6} = 1; -} +def VST2LNq16b: VST2LN<0b0101, "vst2", "16"> { let Inst{5} = 1; } +def VST2LNq32b: VST2LN<0b1001, "vst2", "32"> { let Inst{6} = 1; } // VST3LN : Vector Store (single 3-element structure from one lane) class VST3LN op11_8, string OpcodeStr, string Dt> : NLdSt<1,0b00,op11_8,{?,?,?,?}, (outs), - (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, - nohash_imm:$lane), IIC_VST, - OpcodeStr, Dt, - "\\{$src1[$lane], $src2[$lane], $src3[$lane]\\}, $addr", "", []>; + (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, + nohash_imm:$lane), IIC_VST, OpcodeStr, Dt, + "\\{$src1[$lane], $src2[$lane], $src3[$lane]\\}, $addr", "", []>; // vst3 to single-spaced registers. -def VST3LNd8 : VST3LN<0b0010, "vst3", "8"> { - let Inst{4} = 0; -} -def VST3LNd16 : VST3LN<0b0110, "vst3", "16"> { - let Inst{5-4} = 0b00; -} -def VST3LNd32 : VST3LN<0b1010, "vst3", "32"> { - let Inst{6-4} = 0b000; -} +def VST3LNd8 : VST3LN<0b0010, "vst3", "8"> { let Inst{4} = 0; } +def VST3LNd16 : VST3LN<0b0110, "vst3", "16"> { let Inst{5-4} = 0b00; } +def VST3LNd32 : VST3LN<0b1010, "vst3", "32"> { let Inst{6-4} = 0b000; } // vst3 to double-spaced even registers. -def VST3LNq16a: VST3LN<0b0110, "vst3", "16"> { - let Inst{5-4} = 0b10; -} -def VST3LNq32a: VST3LN<0b1010, "vst3", "32"> { - let Inst{6-4} = 0b100; -} +def VST3LNq16a: VST3LN<0b0110, "vst3", "16"> { let Inst{5-4} = 0b10; } +def VST3LNq32a: VST3LN<0b1010, "vst3", "32"> { let Inst{6-4} = 0b100; } // vst3 to double-spaced odd registers. -def VST3LNq16b: VST3LN<0b0110, "vst3", "16"> { - let Inst{5-4} = 0b10; -} -def VST3LNq32b: VST3LN<0b1010, "vst3", "32"> { - let Inst{6-4} = 0b100; -} +def VST3LNq16b: VST3LN<0b0110, "vst3", "16"> { let Inst{5-4} = 0b10; } +def VST3LNq32b: VST3LN<0b1010, "vst3", "32"> { let Inst{6-4} = 0b100; } // VST4LN : Vector Store (single 4-element structure from one lane) class VST4LN op11_8, string OpcodeStr, string Dt> : NLdSt<1,0b00,op11_8,{?,?,?,?}, (outs), - (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4, - nohash_imm:$lane), IIC_VST, - OpcodeStr, Dt, + (ins addrmode6:$addr, DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4, + nohash_imm:$lane), IIC_VST, OpcodeStr, Dt, "\\{$src1[$lane], $src2[$lane], $src3[$lane], $src4[$lane]\\}, $addr", - "", []>; + "", []>; // vst4 to single-spaced registers. def VST4LNd8 : VST4LN<0b0011, "vst4", "8">; -def VST4LNd16 : VST4LN<0b0111, "vst4", "16"> { - let Inst{5} = 0; -} -def VST4LNd32 : VST4LN<0b1011, "vst4", "32"> { - let Inst{6} = 0; -} +def VST4LNd16 : VST4LN<0b0111, "vst4", "16"> { let Inst{5} = 0; } +def VST4LNd32 : VST4LN<0b1011, "vst4", "32"> { let Inst{6} = 0; } // vst4 to double-spaced even registers. -def VST4LNq16a: VST4LN<0b0111, "vst4", "16"> { - let Inst{5} = 1; -} -def VST4LNq32a: VST4LN<0b1011, "vst4", "32"> { - let Inst{6} = 1; -} +def VST4LNq16a: VST4LN<0b0111, "vst4", "16"> { let Inst{5} = 1; } +def VST4LNq32a: VST4LN<0b1011, "vst4", "32"> { let Inst{6} = 1; } // vst4 to double-spaced odd registers. -def VST4LNq16b: VST4LN<0b0111, "vst4", "16"> { - let Inst{5} = 1; -} -def VST4LNq32b: VST4LN<0b1011, "vst4", "32"> { - let Inst{6} = 1; -} +def VST4LNq16b: VST4LN<0b0111, "vst4", "16"> { let Inst{5} = 1; } +def VST4LNq32b: VST4LN<0b1011, "vst4", "32"> { let Inst{6} = 1; } } // mayStore = 1, hasExtraSrcRegAllocReq = 1 @@ -672,17 +582,17 @@ // Basic 2-register operations, scalar single-precision. class N2VDs op24_23, bits<2> op21_20, bits<2> op19_18, - bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr,string Dt, - ValueType ResTy, ValueType OpTy, SDNode OpNode> + bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr, + string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode> : N2V; class N2VDsPat : NEONFPPat<(ResTy (OpNode SPR:$a)), - (EXTRACT_SUBREG - (Inst (INSERT_SUBREG (OpTy (IMPLICIT_DEF)), SPR:$a, arm_ssubreg_0)), - arm_ssubreg_0)>; + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (OpTy (IMPLICIT_DEF)), + SPR:$a, arm_ssubreg_0)), + arm_ssubreg_0)>; // Basic 2-register intrinsics, both double- and quad-register. class N2VDInt op24_23, bits<2> op21_20, bits<2> op19_18, @@ -702,18 +612,18 @@ // Basic 2-register intrinsics, scalar single-precision class N2VDInts op24_23, bits<2> op21_20, bits<2> op19_18, - bits<2> op17_16, bits<5> op11_7, bit op4, - InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, Intrinsic IntOp> + bits<2> op17_16, bits<5> op11_7, bit op4, + InstrItinClass itin, string OpcodeStr, string Dt, + ValueType ResTy, ValueType OpTy, Intrinsic IntOp> : N2V; class N2VDIntsPat : NEONFPPat<(f32 (OpNode SPR:$a)), - (EXTRACT_SUBREG - (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$a, arm_ssubreg_0)), - arm_ssubreg_0)>; + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$a, arm_ssubreg_0)), + arm_ssubreg_0)>; // Narrow 2-register intrinsics. class N2VNInt op24_23, bits<2> op21_20, bits<2> op19_18, @@ -742,15 +652,13 @@ class N2VQShuffle op19_18, bits<5> op11_7, InstrItinClass itin, string OpcodeStr, string Dt> : N2V<0b11, 0b11, op19_18, 0b10, op11_7, 1, 0, (outs QPR:$dst1, QPR:$dst2), - (ins QPR:$src1, QPR:$src2), itin, - OpcodeStr, Dt, "$dst1, $dst2", + (ins QPR:$src1, QPR:$src2), itin, OpcodeStr, Dt, "$dst1, $dst2", "$src1 = $dst1, $src2 = $dst2", []>; // Basic 3-register operations, both double- and quad-register. class N3VD op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, - SDNode OpNode, bit Commutable> + ValueType ResTy, ValueType OpTy, SDNode OpNode, bit Commutable> : N3V : N3VX { + (outs DPR:$dst), (ins DPR:$src1, DPR:$src2), itin, + OpcodeStr, "$dst, $src1, $src2", "", + [(set DPR:$dst, (ResTy (OpNode (OpTy DPR:$src1), (OpTy DPR:$src2))))]>{ let isCommutable = Commutable; } class N3VDSL op21_20, bits<4> op11_8, @@ -776,27 +684,23 @@ itin, OpcodeStr, Dt, "$dst, $src1, $src2[$lane]", "", [(set (Ty DPR:$dst), (Ty (ShOp (Ty DPR:$src1), - (Ty (NEONvduplane (Ty DPR_VFP2:$src2), - imm:$lane)))))]> { + (Ty (NEONvduplane (Ty DPR_VFP2:$src2), imm:$lane)))))]>{ let isCommutable = 0; } class N3VDSL16 op21_20, bits<4> op11_8, string OpcodeStr, string Dt, ValueType Ty, SDNode ShOp> : N3V<0, 1, op21_20, op11_8, 1, 0, (outs DPR:$dst), (ins DPR:$src1, DPR_8:$src2, nohash_imm:$lane), - IIC_VMULi16D, - OpcodeStr, Dt, "$dst, $src1, $src2[$lane]", "", + IIC_VMULi16D, OpcodeStr, Dt, "$dst, $src1, $src2[$lane]", "", [(set (Ty DPR:$dst), (Ty (ShOp (Ty DPR:$src1), - (Ty (NEONvduplane (Ty DPR_8:$src2), - imm:$lane)))))]> { + (Ty (NEONvduplane (Ty DPR_8:$src2), imm:$lane)))))]> { let isCommutable = 0; } class N3VQ op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, - SDNode OpNode, bit Commutable> + ValueType ResTy, ValueType OpTy, SDNode OpNode, bit Commutable> : N3V op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, - ValueType ResTy, ValueType OpTy, - SDNode OpNode, bit Commutable> + ValueType ResTy, ValueType OpTy, SDNode OpNode, bit Commutable> : N3VX { + (outs QPR:$dst), (ins QPR:$src1, QPR:$src2), itin, + OpcodeStr, "$dst, $src1, $src2", "", + [(set QPR:$dst, (ResTy (OpNode (OpTy QPR:$src1), (OpTy QPR:$src2))))]>{ let isCommutable = Commutable; } class N3VQSL op21_20, bits<4> op11_8, @@ -825,13 +728,11 @@ imm:$lane)))))]> { let isCommutable = 0; } -class N3VQSL16 op21_20, bits<4> op11_8, - string OpcodeStr, string Dt, +class N3VQSL16 op21_20, bits<4> op11_8, string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, SDNode ShOp> : N3V<1, 1, op21_20, op11_8, 1, 0, (outs QPR:$dst), (ins QPR:$src1, DPR_8:$src2, nohash_imm:$lane), - IIC_VMULi16Q, - OpcodeStr, Dt, "$dst, $src1, $src2[$lane]", "", + IIC_VMULi16Q, OpcodeStr, Dt, "$dst, $src1, $src2[$lane]", "", [(set (ResTy QPR:$dst), (ResTy (ShOp (ResTy QPR:$src1), (ResTy (NEONvduplane (OpTy DPR_8:$src2), @@ -841,8 +742,8 @@ // Basic 3-register operations, scalar single-precision class N3VDs op21_20, bits<4> op11_8, bit op4, - string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, - SDNode OpNode, bit Commutable> + string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, + SDNode OpNode, bit Commutable> : N3V { @@ -850,16 +751,16 @@ } class N3VDsPat : NEONFPPat<(f32 (OpNode SPR:$a, SPR:$b)), - (EXTRACT_SUBREG - (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$a, arm_ssubreg_0), - (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$b, arm_ssubreg_0)), - arm_ssubreg_0)>; + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$a, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$b, arm_ssubreg_0)), + arm_ssubreg_0)>; // Basic 3-register intrinsics, both double- and quad-register. class N3VDInt op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, - Intrinsic IntOp, bit Commutable> + ValueType ResTy, ValueType OpTy, Intrinsic IntOp, bit Commutable> : N3V op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, - Intrinsic IntOp, bit Commutable> + ValueType ResTy, ValueType OpTy, Intrinsic IntOp, bit Commutable> : N3V; + (ResTy (NEONvduplane (OpTy DPR_VFP2:$src3), + imm:$lane)))))))]>; class N3VQMulOpSL16 op21_20, bits<4> op11_8, InstrItinClass itin, string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, @@ -989,8 +889,8 @@ [(set (ResTy QPR:$dst), (ResTy (ShOp (ResTy QPR:$src1), (ResTy (MulOp QPR:$src2, - (ResTy (NEONvduplane (OpTy DPR_8:$src3), - imm:$lane)))))))]>; + (ResTy (NEONvduplane (OpTy DPR_8:$src3), + imm:$lane)))))))]>; // Multiply-Add/Sub operations, scalar single-precision class N3VDMulOps op21_20, bits<4> op11_8, bit op4, @@ -1003,11 +903,13 @@ class N3VDMulOpsPat : NEONFPPat<(f32 (OpNode SPR:$acc, (f32 (MulNode SPR:$a, SPR:$b)))), - (EXTRACT_SUBREG - (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$acc, arm_ssubreg_0), - (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$a, arm_ssubreg_0), - (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$b, arm_ssubreg_0)), - arm_ssubreg_0)>; + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$acc, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$a, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$b, arm_ssubreg_0)), + arm_ssubreg_0)>; // Neon 3-argument intrinsics, both double- and quad-register. // The destination register is also used as the first source operand register. @@ -1050,9 +952,9 @@ (OpTy DPR:$src2), (OpTy (NEONvduplane (OpTy DPR_VFP2:$src3), imm:$lane)))))]>; -class N3VLInt3SL16 op21_20, bits<4> op11_8, InstrItinClass itin, - string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, - Intrinsic IntOp> +class N3VLInt3SL16 op21_20, bits<4> op11_8, + InstrItinClass itin, string OpcodeStr, string Dt, + ValueType ResTy, ValueType OpTy, Intrinsic IntOp> : N3V; - // Narrowing 3-register intrinsics. class N3VNInt op21_20, bits<4> op11_8, bit op4, string OpcodeStr, string Dt, ValueType TyD, ValueType TyQ, @@ -1095,9 +996,9 @@ (ResTy (IntOp (OpTy DPR:$src1), (OpTy (NEONvduplane (OpTy DPR_VFP2:$src2), imm:$lane)))))]>; -class N3VLIntSL16 op21_20, bits<4> op11_8, InstrItinClass itin, - string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, - Intrinsic IntOp> +class N3VLIntSL16 op21_20, bits<4> op11_8, + InstrItinClass itin, string OpcodeStr, string Dt, + ValueType ResTy, ValueType OpTy, Intrinsic IntOp> : N3V; def v4i16 : N3VD; + OpcodeStr, !strconcat(Dt, "16"), + v4i16, v4i16, OpNode, Commutable>; def v2i32 : N3VD; + OpcodeStr, !strconcat(Dt, "32"), + v2i32, v2i32, OpNode, Commutable>; // 128-bit vector types. def v16i8 : N3VQ; + OpcodeStr, !strconcat(Dt, "8"), + v16i8, v16i8, OpNode, Commutable>; def v8i16 : N3VQ; + OpcodeStr, !strconcat(Dt, "16"), + v8i16, v8i16, OpNode, Commutable>; def v4i32 : N3VQ; + OpcodeStr, !strconcat(Dt, "32"), + v4i32, v4i32, OpNode, Commutable>; } multiclass N3VSL_HS op11_8, string OpcodeStr, string Dt, SDNode ShOp> { @@ -1372,7 +1273,7 @@ def v2i32 : N3VDIntSL<0b10, op11_8, itinD32, OpcodeStr, !strconcat(Dt, "32"), v2i32, IntOp>; def v8i16 : N3VQIntSL16<0b01, op11_8, itinQ16, - OpcodeStr, !strconcat(Dt, "16"), v8i16, v4i16, IntOp>; + OpcodeStr, !strconcat(Dt, "16"), v8i16, v4i16, IntOp>; def v4i32 : N3VQIntSL<0b10, op11_8, itinQ32, OpcodeStr, !strconcat(Dt, "32"), v4i32, v2i32, IntOp>; } @@ -1386,8 +1287,8 @@ : N3VInt_HS { def v8i8 : N3VDInt; + OpcodeStr, !strconcat(Dt, "8"), + v8i8, v8i8, IntOp, Commutable>; def v16i8 : N3VQInt; @@ -1402,11 +1303,11 @@ : N3VInt_QHS { def v1i64 : N3VDInt; + OpcodeStr, !strconcat(Dt, "64"), + v1i64, v1i64, IntOp, Commutable>; def v2i64 : N3VQInt; + OpcodeStr, !strconcat(Dt, "64"), + v2i64, v2i64, IntOp, Commutable>; } @@ -1511,9 +1412,11 @@ def v2i32 : N3VDMulOpSL<0b10, op11_8, itinD32, OpcodeStr, !strconcat(Dt, "32"), v2i32, mul, ShOp>; def v8i16 : N3VQMulOpSL16<0b01, op11_8, itinQ16, - OpcodeStr, !strconcat(Dt, "16"), v8i16, v4i16, mul, ShOp>; + OpcodeStr, !strconcat(Dt, "16"), v8i16, v4i16, + mul, ShOp>; def v4i32 : N3VQMulOpSL<0b10, op11_8, itinQ32, - OpcodeStr, !strconcat(Dt, "32"), v4i32, v2i32, mul, ShOp>; + OpcodeStr, !strconcat(Dt, "32"), v4i32, v2i32, + mul, ShOp>; } // Neon 3-argument intrinsics, @@ -1522,19 +1425,19 @@ string OpcodeStr, string Dt, Intrinsic IntOp> { // 64-bit vector types. def v8i8 : N3VDInt3; + OpcodeStr, !strconcat(Dt, "8"), v8i8, v8i8, IntOp>; def v4i16 : N3VDInt3; + OpcodeStr, !strconcat(Dt, "16"), v4i16, v4i16, IntOp>; def v2i32 : N3VDInt3; + OpcodeStr, !strconcat(Dt, "32"), v2i32, v2i32, IntOp>; // 128-bit vector types. def v16i8 : N3VQInt3; + OpcodeStr, !strconcat(Dt, "8"), v16i8, v16i8, IntOp>; def v8i16 : N3VQInt3; + OpcodeStr, !strconcat(Dt, "16"), v8i16, v8i16, IntOp>; def v4i32 : N3VQInt3; + OpcodeStr, !strconcat(Dt, "32"), v4i32, v4i32, IntOp>; } @@ -1576,17 +1479,17 @@ def v8i8 : N2VDInt; def v4i16 : N2VDInt; + itinD, OpcodeStr, !strconcat(Dt, "16"),v4i16,v4i16,IntOp>; def v2i32 : N2VDInt; + itinD, OpcodeStr, !strconcat(Dt, "32"),v2i32,v2i32,IntOp>; // 128-bit vector types. def v16i8 : N2VQInt; + itinQ, OpcodeStr, !strconcat(Dt, "8"), v16i8,v16i8,IntOp>; def v8i16 : N2VQInt; + itinQ, OpcodeStr, !strconcat(Dt, "16"),v8i16,v8i16,IntOp>; def v4i32 : N2VQInt; + itinQ, OpcodeStr, !strconcat(Dt, "32"),v4i32,v4i32,IntOp>; } @@ -1846,29 +1749,31 @@ def VMULpq : N3VQInt<1, 0, 0b00, 0b1001, 1, IIC_VMULi16Q, "vmul", "p8", v16i8, v16i8, int_arm_neon_vmulp, 1>; def VMULfd : N3VD<1, 0, 0b00, 0b1101, 1, IIC_VBIND, "vmul", "f32", - v2f32, v2f32, fmul, 1>; + v2f32, v2f32, fmul, 1>; def VMULfq : N3VQ<1, 0, 0b00, 0b1101, 1, IIC_VBINQ, "vmul", "f32", - v4f32, v4f32, fmul, 1>; -defm VMULsl : N3VSL_HS<0b1000, "vmul", "i", mul>; -def VMULslfd : N3VDSL<0b10, 0b1001, IIC_VBIND, "vmul", "f32", v2f32, fmul>; -def VMULslfq : N3VQSL<0b10, 0b1001, IIC_VBINQ, "vmul", "f32", v4f32, v2f32, fmul>; + v4f32, v4f32, fmul, 1>; +defm VMULsl : N3VSL_HS<0b1000, "vmul", "i", mul>; +def VMULslfd : N3VDSL<0b10, 0b1001, IIC_VBIND, "vmul", "f32", v2f32, fmul>; +def VMULslfq : N3VQSL<0b10, 0b1001, IIC_VBINQ, "vmul", "f32", v4f32, + v2f32, fmul>; + def : Pat<(v8i16 (mul (v8i16 QPR:$src1), (v8i16 (NEONvduplane (v8i16 QPR:$src2), imm:$lane)))), (v8i16 (VMULslv8i16 (v8i16 QPR:$src1), (v4i16 (EXTRACT_SUBREG QPR:$src2, - (DSubReg_i16_reg imm:$lane))), + (DSubReg_i16_reg imm:$lane))), (SubReg_i16_lane imm:$lane)))>; def : Pat<(v4i32 (mul (v4i32 QPR:$src1), (v4i32 (NEONvduplane (v4i32 QPR:$src2), imm:$lane)))), (v4i32 (VMULslv4i32 (v4i32 QPR:$src1), (v2i32 (EXTRACT_SUBREG QPR:$src2, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; def : Pat<(v4f32 (fmul (v4f32 QPR:$src1), (v4f32 (NEONvduplane (v4f32 QPR:$src2), imm:$lane)))), (v4f32 (VMULslfq (v4f32 QPR:$src1), (v2f32 (EXTRACT_SUBREG QPR:$src2, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; // VQDMULH : Vector Saturating Doubling Multiply Returning High Half @@ -1883,14 +1788,14 @@ imm:$lane)))), (v8i16 (VQDMULHslv8i16 (v8i16 QPR:$src1), (v4i16 (EXTRACT_SUBREG QPR:$src2, - (DSubReg_i16_reg imm:$lane))), + (DSubReg_i16_reg imm:$lane))), (SubReg_i16_lane imm:$lane)))>; def : Pat<(v4i32 (int_arm_neon_vqdmulh (v4i32 QPR:$src1), (v4i32 (NEONvduplane (v4i32 QPR:$src2), imm:$lane)))), (v4i32 (VQDMULHslv4i32 (v4i32 QPR:$src1), (v2i32 (EXTRACT_SUBREG QPR:$src2, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; // VQRDMULH : Vector Rounding Saturating Doubling Multiply Returning High Half @@ -1905,14 +1810,14 @@ imm:$lane)))), (v8i16 (VQRDMULHslv8i16 (v8i16 QPR:$src1), (v4i16 (EXTRACT_SUBREG QPR:$src2, - (DSubReg_i16_reg imm:$lane))), + (DSubReg_i16_reg imm:$lane))), (SubReg_i16_lane imm:$lane)))>; def : Pat<(v4i32 (int_arm_neon_vqrdmulh (v4i32 QPR:$src1), (v4i32 (NEONvduplane (v4i32 QPR:$src2), imm:$lane)))), (v4i32 (VQRDMULHslv4i32 (v4i32 QPR:$src1), (v2i32 (EXTRACT_SUBREG QPR:$src2, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; // VMULL : Vector Multiply Long (integer and polynomial) (Q = D * D) @@ -1950,30 +1855,28 @@ v4f32, v2f32, fmul, fadd>; def : Pat<(v8i16 (add (v8i16 QPR:$src1), - (mul (v8i16 QPR:$src2), - (v8i16 (NEONvduplane (v8i16 QPR:$src3), imm:$lane))))), - (v8i16 (VMLAslv8i16 (v8i16 QPR:$src1), - (v8i16 QPR:$src2), + (mul (v8i16 QPR:$src2), + (v8i16 (NEONvduplane (v8i16 QPR:$src3), imm:$lane))))), + (v8i16 (VMLAslv8i16 (v8i16 QPR:$src1), (v8i16 QPR:$src2), (v4i16 (EXTRACT_SUBREG QPR:$src3, - (DSubReg_i16_reg imm:$lane))), + (DSubReg_i16_reg imm:$lane))), (SubReg_i16_lane imm:$lane)))>; def : Pat<(v4i32 (add (v4i32 QPR:$src1), - (mul (v4i32 QPR:$src2), - (v4i32 (NEONvduplane (v4i32 QPR:$src3), imm:$lane))))), - (v4i32 (VMLAslv4i32 (v4i32 QPR:$src1), - (v4i32 QPR:$src2), + (mul (v4i32 QPR:$src2), + (v4i32 (NEONvduplane (v4i32 QPR:$src3), imm:$lane))))), + (v4i32 (VMLAslv4i32 (v4i32 QPR:$src1), (v4i32 QPR:$src2), (v2i32 (EXTRACT_SUBREG QPR:$src3, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; def : Pat<(v4f32 (fadd (v4f32 QPR:$src1), - (fmul (v4f32 QPR:$src2), - (v4f32 (NEONvduplane (v4f32 QPR:$src3), imm:$lane))))), + (fmul (v4f32 QPR:$src2), + (v4f32 (NEONvduplane (v4f32 QPR:$src3), imm:$lane))))), (v4f32 (VMLAslfq (v4f32 QPR:$src1), (v4f32 QPR:$src2), (v2f32 (EXTRACT_SUBREG QPR:$src3, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; // VMLAL : Vector Multiply Accumulate Long (Q += D * D) @@ -2003,30 +1906,27 @@ v4f32, v2f32, fmul, fsub>; def : Pat<(v8i16 (sub (v8i16 QPR:$src1), - (mul (v8i16 QPR:$src2), - (v8i16 (NEONvduplane (v8i16 QPR:$src3), imm:$lane))))), - (v8i16 (VMLSslv8i16 (v8i16 QPR:$src1), - (v8i16 QPR:$src2), + (mul (v8i16 QPR:$src2), + (v8i16 (NEONvduplane (v8i16 QPR:$src3), imm:$lane))))), + (v8i16 (VMLSslv8i16 (v8i16 QPR:$src1), (v8i16 QPR:$src2), (v4i16 (EXTRACT_SUBREG QPR:$src3, - (DSubReg_i16_reg imm:$lane))), + (DSubReg_i16_reg imm:$lane))), (SubReg_i16_lane imm:$lane)))>; def : Pat<(v4i32 (sub (v4i32 QPR:$src1), - (mul (v4i32 QPR:$src2), - (v4i32 (NEONvduplane (v4i32 QPR:$src3), imm:$lane))))), - (v4i32 (VMLSslv4i32 (v4i32 QPR:$src1), - (v4i32 QPR:$src2), + (mul (v4i32 QPR:$src2), + (v4i32 (NEONvduplane (v4i32 QPR:$src3), imm:$lane))))), + (v4i32 (VMLSslv4i32 (v4i32 QPR:$src1), (v4i32 QPR:$src2), (v2i32 (EXTRACT_SUBREG QPR:$src3, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; def : Pat<(v4f32 (fsub (v4f32 QPR:$src1), - (fmul (v4f32 QPR:$src2), - (v4f32 (NEONvduplane (v4f32 QPR:$src3), imm:$lane))))), - (v4f32 (VMLSslfq (v4f32 QPR:$src1), - (v4f32 QPR:$src2), + (fmul (v4f32 QPR:$src2), + (v4f32 (NEONvduplane (v4f32 QPR:$src3), imm:$lane))))), + (v4f32 (VMLSslfq (v4f32 QPR:$src1), (v4f32 QPR:$src2), (v2f32 (EXTRACT_SUBREG QPR:$src3, - (DSubReg_i32_reg imm:$lane))), + (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane)))>; // VMLSL : Vector Multiply Subtract Long (Q -= D * D) @@ -2247,9 +2147,9 @@ // Vector Maximum and Minimum. // VMAX : Vector Maximum -defm VMAXs : N3VInt_QHS<0, 0, 0b0110, 0, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, +defm VMAXs : N3VInt_QHS<0,0,0b0110,0, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q, "vmax", "s", int_arm_neon_vmaxs, 1>; -defm VMAXu : N3VInt_QHS<1, 0, 0b0110, 0, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, +defm VMAXu : N3VInt_QHS<1,0,0b0110,0, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q, "vmax", "u", int_arm_neon_vmaxu, 1>; def VMAXfd : N3VDInt<0, 0, 0b00, 0b1111, 0, IIC_VBIND, "vmax", "f32", v2f32, v2f32, int_arm_neon_vmaxs, 1>; @@ -2257,9 +2157,9 @@ v4f32, v4f32, int_arm_neon_vmaxs, 1>; // VMIN : Vector Minimum -defm VMINs : N3VInt_QHS<0, 0, 0b0110, 1, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, +defm VMINs : N3VInt_QHS<0,0,0b0110,1, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q, "vmin", "s", int_arm_neon_vmins, 1>; -defm VMINu : N3VInt_QHS<1, 0, 0b0110, 1, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, +defm VMINu : N3VInt_QHS<1,0,0b0110,1, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q, "vmin", "u", int_arm_neon_vminu, 1>; def VMINfd : N3VDInt<0, 0, 0b10, 0b1111, 0, IIC_VBIND, "vmin", "f32", v2f32, v2f32, int_arm_neon_vmins, 1>; @@ -2401,16 +2301,17 @@ v2i64, v2i32, NEONvshlli>; // VSHRN : Vector Shift Right and Narrow -defm VSHRN : N2VNSh_HSD<0,1,0b1000,0,0,1, IIC_VSHLiD, "vshrn", "i", NEONvshrn>; +defm VSHRN : N2VNSh_HSD<0,1,0b1000,0,0,1, IIC_VSHLiD, "vshrn", "i", + NEONvshrn>; // VRSHL : Vector Rounding Shift defm VRSHLs : N3VInt_QHSD<0,0,0b0101,0, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, - IIC_VSHLi4Q, "vrshl", "s", int_arm_neon_vrshifts, 0>; + IIC_VSHLi4Q, "vrshl", "s", int_arm_neon_vrshifts,0>; defm VRSHLu : N3VInt_QHSD<1,0,0b0101,0, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, - IIC_VSHLi4Q, "vrshl", "u", int_arm_neon_vrshiftu, 0>; + IIC_VSHLi4Q, "vrshl", "u", int_arm_neon_vrshiftu,0>; // VRSHR : Vector Rounding Shift Right -defm VRSHRs : N2VSh_QHSD<0, 1, 0b0010, 1, IIC_VSHLi4D, "vrshr", "s", NEONvrshrs>; -defm VRSHRu : N2VSh_QHSD<1, 1, 0b0010, 1, IIC_VSHLi4D, "vrshr", "u", NEONvrshru>; +defm VRSHRs : N2VSh_QHSD<0,1,0b0010,1, IIC_VSHLi4D, "vrshr", "s", NEONvrshrs>; +defm VRSHRu : N2VSh_QHSD<1,1,0b0010,1, IIC_VSHLi4D, "vrshr", "u", NEONvrshru>; // VRSHRN : Vector Rounding Shift Right and Narrow defm VRSHRN : N2VNSh_HSD<0, 1, 0b1000, 0, 1, 1, IIC_VSHLi4D, "vrshrn", "i", @@ -2418,14 +2319,14 @@ // VQSHL : Vector Saturating Shift defm VQSHLs : N3VInt_QHSD<0,0,0b0100,1, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, - IIC_VSHLi4Q, "vqshl", "s", int_arm_neon_vqshifts, 0>; + IIC_VSHLi4Q, "vqshl", "s", int_arm_neon_vqshifts,0>; defm VQSHLu : N3VInt_QHSD<1,0,0b0100,1, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, - IIC_VSHLi4Q, "vqshl", "u", int_arm_neon_vqshiftu, 0>; + IIC_VSHLi4Q, "vqshl", "u", int_arm_neon_vqshiftu,0>; // VQSHL : Vector Saturating Shift Left (Immediate) -defm VQSHLsi : N2VSh_QHSD<0, 1, 0b0111, 1, IIC_VSHLi4D, "vqshl", "s", NEONvqshls>; -defm VQSHLui : N2VSh_QHSD<1, 1, 0b0111, 1, IIC_VSHLi4D, "vqshl", "u", NEONvqshlu>; +defm VQSHLsi : N2VSh_QHSD<0,1,0b0111,1, IIC_VSHLi4D, "vqshl", "s", NEONvqshls>; +defm VQSHLui : N2VSh_QHSD<1,1,0b0111,1, IIC_VSHLi4D, "vqshl", "u", NEONvqshlu>; // VQSHLU : Vector Saturating Shift Left (Immediate, Unsigned) -defm VQSHLsu : N2VSh_QHSD<1, 1, 0b0110, 1, IIC_VSHLi4D, "vqshlu", "s", NEONvqshlsu>; +defm VQSHLsu : N2VSh_QHSD<1,1,0b0110,1, IIC_VSHLi4D, "vqshlu","s",NEONvqshlsu>; // VQSHRN : Vector Saturating Shift Right and Narrow defm VQSHRNs : N2VNSh_HSD<0, 1, 0b1001, 0, 0, 1, IIC_VSHLi4D, "vqshrn", "s", @@ -2438,10 +2339,10 @@ NEONvqshrnsu>; // VQRSHL : Vector Saturating Rounding Shift -defm VQRSHLs : N3VInt_QHSD<0, 0, 0b0101, 1, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, +defm VQRSHLs : N3VInt_QHSD<0,0,0b0101,1, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q, "vqrshl", "s", int_arm_neon_vqrshifts, 0>; -defm VQRSHLu : N3VInt_QHSD<1, 0, 0b0101, 1, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, +defm VQRSHLu : N3VInt_QHSD<1,0,0b0101,1, IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q, "vqrshl", "u", int_arm_neon_vqrshiftu, 0>; @@ -2678,10 +2579,10 @@ (DSubReg_i32_reg imm:$lane))), (SubReg_i32_lane imm:$lane))>; def : Pat<(extractelt (v2f32 DPR:$src1), imm:$src2), - (EXTRACT_SUBREG (v2f32 (COPY_TO_REGCLASS (v2f32 DPR:$src1), DPR_VFP2)), + (EXTRACT_SUBREG (v2f32 (COPY_TO_REGCLASS (v2f32 DPR:$src1),DPR_VFP2)), (SSubReg_f32_reg imm:$src2))>; def : Pat<(extractelt (v4f32 QPR:$src1), imm:$src2), - (EXTRACT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4f32 QPR:$src1), QPR_VFP2)), + (EXTRACT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4f32 QPR:$src1),QPR_VFP2)), (SSubReg_f32_reg imm:$src2))>; //def : Pat<(extractelt (v2i64 QPR:$src1), imm:$src2), // (EXTRACT_SUBREG QPR:$src1, (DSubReg_f64_reg imm:$src2))>; @@ -2849,11 +2750,13 @@ def : Pat<(v2i64 (NEONvduplane (v2i64 QPR:$src), imm:$lane)), (INSERT_SUBREG QPR:$src, - (i64 (EXTRACT_SUBREG QPR:$src, (DSubReg_f64_reg imm:$lane))), + (i64 (EXTRACT_SUBREG QPR:$src, + (DSubReg_f64_reg imm:$lane))), (DSubReg_f64_other_reg imm:$lane))>; def : Pat<(v2f64 (NEONvduplane (v2f64 QPR:$src), imm:$lane)), (INSERT_SUBREG QPR:$src, - (f64 (EXTRACT_SUBREG QPR:$src, (DSubReg_f64_reg imm:$lane))), + (f64 (EXTRACT_SUBREG QPR:$src, + (DSubReg_f64_reg imm:$lane))), (DSubReg_f64_other_reg imm:$lane))>; // VMOVN : Vector Narrowing Move @@ -3097,17 +3000,17 @@ // Vector Add Operations used for single-precision FP let neverHasSideEffects = 1 in -def VADDfd_sfp : N3VDs<0, 0, 0b00, 0b1101, 0, "vadd", "f32", v2f32, v2f32, fadd,1>; +def VADDfd_sfp : N3VDs<0,0,0b00,0b1101,0, "vadd", "f32", v2f32, v2f32, fadd, 1>; def : N3VDsPat; // Vector Sub Operations used for single-precision FP let neverHasSideEffects = 1 in -def VSUBfd_sfp : N3VDs<0, 0, 0b10, 0b1101, 0, "vsub", "f32", v2f32, v2f32, fsub,0>; +def VSUBfd_sfp : N3VDs<0,0,0b10,0b1101,0, "vsub", "f32", v2f32, v2f32, fsub, 0>; def : N3VDsPat; // Vector Multiply Operations used for single-precision FP let neverHasSideEffects = 1 in -def VMULfd_sfp : N3VDs<1, 0, 0b00, 0b1101, 1, "vmul", "f32", v2f32, v2f32, fmul,1>; +def VMULfd_sfp : N3VDs<1,0,0b00,0b1101,1, "vmul", "f32", v2f32, v2f32, fmul, 1>; def : N3VDsPat; // Vector Multiply-Accumulate/Subtract used for single-precision FP @@ -3115,18 +3018,19 @@ // we want to avoid them for now. e.g., alternating vmla/vadd instructions. //let neverHasSideEffects = 1 in -//def VMLAfd_sfp : N3VDMulOps<0, 0, 0b00, 0b1101, 1, IIC_VMACD, "vmla", "f32", v2f32,fmul,fadd>; +//def VMLAfd_sfp : N3VDMulOps<0,0,0b00,0b1101,1, IIC_VMACD, "vmla", "f32", +// v2f32, fmul, fadd>; //def : N3VDMulOpsPat; //let neverHasSideEffects = 1 in -//def VMLSfd_sfp : N3VDMulOps<0, 0, 0b10, 0b1101, 1, IIC_VMACD, "vmls", "f32", v2f32,fmul,fsub>; +//def VMLSfd_sfp : N3VDMulOps<0,0,0b10,0b1101,1, IIC_VMACD, "vmls", "f32", +// v2f32, fmul, fsub>; //def : N3VDMulOpsPat; // Vector Absolute used for single-precision FP let neverHasSideEffects = 1 in -def VABSfd_sfp : N2VDInts<0b11, 0b11, 0b10, 0b01, 0b01110, 0, - IIC_VUNAD, "vabs", "f32", - v2f32, v2f32, int_arm_neon_vabs>; +def VABSfd_sfp : N2VDInts<0b11, 0b11, 0b10, 0b01, 0b01110, 0, IIC_VUNAD, + "vabs", "f32", v2f32, v2f32, int_arm_neon_vabs>; def : N2VDIntsPat; // Vector Negate used for single-precision FP From sabre at nondot.org Tue Feb 16 18:31:50 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 00:31:50 -0000 Subject: [llvm-commits] [llvm] r96419 - in /llvm/trunk/utils/TableGen: DAGISelEmitter.cpp DAGISelMatcher.h DAGISelMatcherEmitter.cpp DAGISelMatcherGen.cpp Message-ID: <201002170031.o1H0VokB019347@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 18:31:50 2010 New Revision: 96419 URL: http://llvm.org/viewvc/llvm-project?rev=96419&view=rev Log: make the new isel generator plop out a CheckComplexPattern function for evaluating complex patterns. Some cleanup has to happen before this can be used though. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96419&r1=96418&r2=96419&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 18:31:50 2010 @@ -697,7 +697,7 @@ Code += ", CPTmp" + RootName + "_" + utostr(i); if (CP->hasProperty(SDNPHasChain)) { ChainName = "Chain" + ChainSuffix; - Code += ", CPInChain, Chain" + ChainSuffix; + Code += ", CPInChain, " + ChainName; } emitCheck(Code + ")"); } Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96419&r1=96418&r2=96419&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Tue Feb 16 18:31:50 2010 @@ -317,6 +317,8 @@ CheckComplexPatMatcherNode(const ComplexPattern &pattern) : MatcherNodeWithChild(CheckComplexPat), Pattern(pattern) {} + const ComplexPattern &getPattern() const { return Pattern; } + static inline bool classof(const MatcherNode *N) { return N->getKind() == CheckComplexPat; } Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96419&r1=96418&r2=96419&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Tue Feb 16 18:31:50 2010 @@ -13,6 +13,7 @@ #include "DAGISelMatcher.h" #include "CodeGenDAGPatterns.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/FormattedStream.h" @@ -69,7 +70,9 @@ StringMap NodePredicateMap, PatternPredicateMap; std::vector NodePredicates, PatternPredicates; - + + DenseMap ComplexPatternMap; + std::vector ComplexPatterns; public: MatcherTableEmitter(formatted_raw_ostream &os) : OS(os) {} @@ -95,6 +98,15 @@ } return Entry-1; } + + unsigned getComplexPat(const ComplexPattern &P) { + unsigned &Entry = ComplexPatternMap[&P]; + if (Entry == 0) { + ComplexPatterns.push_back(&P); + Entry = ComplexPatterns.size(); + } + return Entry-1; + } }; } // end anonymous namespace. @@ -169,7 +181,9 @@ return 2; case MatcherNode::CheckComplexPat: - OS << "OPC_CheckComplexPat, 0/*XXX*/,\n"; + OS << "OPC_CheckComplexPat, " + << getComplexPat(cast(N)->getPattern()) + << ",\n"; return 2; case MatcherNode::CheckAndImm: { @@ -238,6 +252,7 @@ } void MatcherTableEmitter::EmitPredicateFunctions() { + // Emit pattern predicates. OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n"; OS << " switch (PredNo) {\n"; OS << " default: assert(0 && \"Invalid predicate in table?\");\n"; @@ -246,6 +261,7 @@ OS << " }\n"; OS << "}\n\n"; + // Emit Node predicates. OS << "bool CheckNodePredicate(SDNode *N, unsigned PredNo) const {\n"; OS << " switch (PredNo) {\n"; OS << " default: assert(0 && \"Invalid predicate in table?\");\n"; @@ -253,6 +269,28 @@ OS << " case " << i << ": return " << NodePredicates[i] << "(N);\n"; OS << " }\n"; OS << "}\n\n"; + + // Emit CompletePattern matchers. + + OS << "bool CheckComplexPattern(SDNode *Root, SDValue N,\n"; + OS << " unsigned PatternNo, SmallVectorImpl &Result) {\n"; + OS << " switch (PatternNo) {\n"; + OS << " default: assert(0 && \"Invalid pattern # in table?\");\n"; + for (unsigned i = 0, e = ComplexPatterns.size(); i != e; ++i) { + const ComplexPattern &P = *ComplexPatterns[i]; + unsigned NumOps = P.getNumOperands(); + if (P.hasProperty(SDNPHasChain)) + NumOps += 2; // Input and output chains. + OS << " case " << i << ":\n"; + OS << " Result.resize(Result.size()+" << NumOps << ");\n"; + OS << " return " << P.getSelectFunc() << "(Root, N"; + for (unsigned i = 0; i != NumOps; ++i) + OS << ", Result[Result.size()-" << (NumOps-i) << ']'; + OS << ");\n"; + } + OS << " }\n"; + OS << "}\n\n"; + } Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96419&r1=96418&r2=96419&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 18:31:50 2010 @@ -273,19 +273,25 @@ if (!N->getName().empty()) { unsigned &VarMapEntry = VariableMap[N->getName()]; if (VarMapEntry == 0) { - VarMapEntry = ++NextRecordedOperandNo; + VarMapEntry = NextRecordedOperandNo+1; + + unsigned NumRecorded; // If this is a complex pattern, the match operation for it will // implicitly record all of the outputs of it (which may be more than // one). if (const ComplexPattern *AM = N->getComplexPatternInfo(CGP)) { // Record the right number of operands. - // FIXME: Does this include chain? - VarMapEntry += AM->getNumOperands()-1; + NumRecorded = AM->getNumOperands()-1; + + if (AM->hasProperty(SDNPHasChain)) + NumRecorded += 2; // Input and output chains. } else { // If it is a normal named node, we must emit a 'Record' opcode. AddMatcherNode(new RecordMatcherNode()); + NumRecorded = 1; } + NextRecordedOperandNo += NumRecorded; } else { // If we get here, this is a second reference to a specific name. Since From gohman at apple.com Tue Feb 16 18:37:21 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 00:37:21 -0000 Subject: [llvm-commits] [llvm] r96421 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Message-ID: <201002170037.o1H0bLIP019599@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 18:37:20 2010 New Revision: 96421 URL: http://llvm.org/viewvc/llvm-project?rev=96421&view=rev Log: Make the operand and format specifier match, and print all 64 bits, fixing a variety of problems. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=96421&r1=96420&r2=96421&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Tue Feb 16 18:37:20 2010 @@ -73,7 +73,7 @@ O << '$' << Op.getImm(); if (CommentStream && (Op.getImm() > 255 || Op.getImm() < -256)) - *CommentStream << format("imm = 0x%X\n", Op.getImm()); + *CommentStream << format("imm = 0x%llX\n", (long long)Op.getImm()); } else { assert(Op.isExpr() && "unknown operand kind in printOperand"); From sabre at nondot.org Tue Feb 16 18:39:26 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 00:39:26 -0000 Subject: [llvm-commits] [llvm] r96422 - /llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Message-ID: <201002170039.o1H0dQsR019702@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 18:39:26 2010 New Revision: 96422 URL: http://llvm.org/viewvc/llvm-project?rev=96422&view=rev Log: improve comments in generated matcher a bit. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96422&r1=96421&r2=96422&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Tue Feb 16 18:39:26 2010 @@ -21,7 +21,7 @@ namespace { enum { - CommentIndent = 25 + CommentIndent = 30 }; } @@ -119,11 +119,11 @@ switch (N->getKind()) { case MatcherNode::Push: assert(0 && "Should be handled by caller"); case MatcherNode::EmitNode: - OS << "OPC_Emit, /*XXX*/"; - OS.PadToColumn(CommentIndent) << "// Src: " - << *cast(N)->getPattern().getSrcPattern() << '\n'; - OS.PadToColumn(CommentIndent) << "// Dst: " - << *cast(N)->getPattern().getDstPattern() << '\n'; + OS << "// Src: " + << *cast(N)->getPattern().getSrcPattern() << '\n'; + OS.PadToColumn(Indent*2) << "// Dst: " + << *cast(N)->getPattern().getDstPattern() << "\n"; + OS.PadToColumn(Indent*2) << "OPC_Emit, /*XXX*/\n\n"; return 1; case MatcherNode::Record: OS << "OPC_Record,\n"; @@ -180,11 +180,13 @@ << cast(N)->getTypeName() << ",\n"; return 2; - case MatcherNode::CheckComplexPat: - OS << "OPC_CheckComplexPat, " - << getComplexPat(cast(N)->getPattern()) - << ",\n"; + case MatcherNode::CheckComplexPat: { + const ComplexPattern &Pattern = + cast(N)->getPattern(); + OS << "OPC_CheckComplexPat, " << getComplexPat(Pattern) << ','; + OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc() << '\n'; return 2; + } case MatcherNode::CheckAndImm: { int64_t Val = cast(N)->getValue(); @@ -271,7 +273,6 @@ OS << "}\n\n"; // Emit CompletePattern matchers. - OS << "bool CheckComplexPattern(SDNode *Root, SDValue N,\n"; OS << " unsigned PatternNo, SmallVectorImpl &Result) {\n"; OS << " switch (PatternNo) {\n"; @@ -290,7 +291,6 @@ } OS << " }\n"; OS << "}\n\n"; - } From sabre at nondot.org Tue Feb 16 18:41:34 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 00:41:34 -0000 Subject: [llvm-commits] [llvm] r96426 - in /llvm/trunk/include/llvm/CodeGen: DAGISelHeader.h SelectionDAGISel.h Message-ID: <201002170041.o1H0fYa8019894@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 18:41:34 2010 New Revision: 96426 URL: http://llvm.org/viewvc/llvm-project?rev=96426&view=rev Log: make the new isel's interpreter loop call the generated CheckComplexPattern function. Though it is logically const, I don't have the fortitude to clean up all the targets now, and it not being const doesn't block anything. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96426&r1=96425&r2=96426&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Tue Feb 16 18:41:34 2010 @@ -319,13 +319,11 @@ case OPC_CheckPredicate: if (!CheckNodePredicate(N.getNode(), MatcherTable[MatcherIndex++])) break; continue; - case OPC_CheckComplexPat: { - unsigned PatNo = MatcherTable[MatcherIndex++]; - (void)PatNo; - // FIXME: CHECK IT. + case OPC_CheckComplexPat: + if (!CheckComplexPattern(NodeToMatch, N, + MatcherTable[MatcherIndex++], RecordedNodes)) + break; continue; - } - case OPC_CheckOpcode: if (N->getOpcode() != MatcherTable[MatcherIndex++]) break; continue; Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=96426&r1=96425&r2=96426&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Tue Feb 16 18:41:34 2010 @@ -131,6 +131,12 @@ return 0; } + virtual bool CheckComplexPattern(SDNode *Root, SDValue N, unsigned PatternNo, + SmallVectorImpl &Result) { + assert(0 && "Tblgen should generate the implementation of this!"); + return false; + } + // Calls to these functions are generated by tblgen. SDNode *Select_INLINEASM(SDNode *N); SDNode *Select_UNDEF(SDNode *N); From gohman at apple.com Tue Feb 16 18:41:54 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 00:41:54 -0000 Subject: [llvm-commits] [llvm] r96428 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/lsr-overflow.ll Message-ID: <201002170041.o1H0fsR2019952@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 18:41:53 2010 New Revision: 96428 URL: http://llvm.org/viewvc/llvm-project?rev=96428&view=rev Log: Don't attempt to divide INT_MIN by -1; consider such cases to have overflowed. Added: llvm/trunk/test/CodeGen/X86/lsr-overflow.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96428&r1=96427&r2=96428&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Feb 16 18:41:53 2010 @@ -2112,12 +2112,16 @@ Formula F = Base; // Check that the multiplication doesn't overflow. + if (F.AM.BaseOffs == INT64_MIN && Factor == -1) + continue; F.AM.BaseOffs = (uint64_t)Base.AM.BaseOffs * Factor; if ((int64_t)F.AM.BaseOffs / Factor != Base.AM.BaseOffs) continue; // Check that multiplying with the use offset doesn't overflow. int64_t Offset = LU.MinOffset; + if (Offset == INT64_MIN && Factor == -1) + continue; Offset = (uint64_t)Offset * Factor; if ((int64_t)Offset / Factor != LU.MinOffset) continue; Added: llvm/trunk/test/CodeGen/X86/lsr-overflow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-overflow.ll?rev=96428&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-overflow.ll (added) +++ llvm/trunk/test/CodeGen/X86/lsr-overflow.ll Tue Feb 16 18:41:53 2010 @@ -0,0 +1,26 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s + +; The comparison uses the pre-inc value, which could lead LSR to +; try to compute -INT64_MIN. + +; CHECK: movabsq $-9223372036854775808, %rax ## imm = 0x8000000000000000 +; CHECK: cmpq %rax, %rbx +; CHECK: sete %al + +declare i64 @bar() + +define i1 @foo() nounwind { +entry: + br label %for.cond.i + +for.cond.i: + %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.cond.i ] + %t = call i64 @bar() + %indvar.next = add i64 %indvar, 1 + %s = icmp ne i64 %indvar.next, %t + br i1 %s, label %for.cond.i, label %__ABContainsLabel.exit + +__ABContainsLabel.exit: + %cmp = icmp eq i64 %indvar, 9223372036854775807 + ret i1 %cmp +} From gohman at apple.com Tue Feb 16 18:42:19 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 00:42:19 -0000 Subject: [llvm-commits] [llvm] r96429 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <201002170042.o1H0gJjG019981@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 18:42:19 2010 New Revision: 96429 URL: http://llvm.org/viewvc/llvm-project?rev=96429&view=rev Log: Delete some unneeded casts. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96429&r1=96428&r2=96429&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Feb 16 18:42:19 2010 @@ -2115,7 +2115,7 @@ if (F.AM.BaseOffs == INT64_MIN && Factor == -1) continue; F.AM.BaseOffs = (uint64_t)Base.AM.BaseOffs * Factor; - if ((int64_t)F.AM.BaseOffs / Factor != Base.AM.BaseOffs) + if (F.AM.BaseOffs / Factor != Base.AM.BaseOffs) continue; // Check that multiplying with the use offset doesn't overflow. @@ -2123,7 +2123,7 @@ if (Offset == INT64_MIN && Factor == -1) continue; Offset = (uint64_t)Offset * Factor; - if ((int64_t)Offset / Factor != LU.MinOffset) + if (Offset / Factor != LU.MinOffset) continue; // Check that this scale is legal. From clattner at apple.com Tue Feb 16 18:50:24 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 16 Feb 2010 16:50:24 -0800 Subject: [llvm-commits] [llvm] r96421 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp In-Reply-To: <201002170037.o1H0bLIP019599@zion.cs.uiuc.edu> References: <201002170037.o1H0bLIP019599@zion.cs.uiuc.edu> Message-ID: <9847F0C4-FDC3-4645-9B32-E8FEEFE17909@apple.com> On Feb 16, 2010, at 4:37 PM, Dan Gohman wrote: > Author: djg > Date: Tue Feb 16 18:37:20 2010 > New Revision: 96421 > > URL: http://llvm.org/viewvc/llvm-project?rev=96421&view=rev > Log: > Make the operand and format specifier match, and print all > 64 bits, fixing a variety of problems. Nice catch, does a similar bug exist in the X86IntelInstPrinter? -Chris > > Modified: > llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp > > Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=96421&r1=96420&r2=96421&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) > +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Tue Feb 16 18:37:20 2010 > @@ -73,7 +73,7 @@ > O << '$' << Op.getImm(); > > if (CommentStream && (Op.getImm() > 255 || Op.getImm() < -256)) > - *CommentStream << format("imm = 0x%X\n", Op.getImm()); > + *CommentStream << format("imm = 0x%llX\n", (long long)Op.getImm()); > > } else { > assert(Op.isExpr() && "unknown operand kind in printOperand"); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Tue Feb 16 18:54:58 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 00:54:58 -0000 Subject: [llvm-commits] [llvm] r96432 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/InstCombine/bswap-fold.ll Message-ID: <201002170054.o1H0swe6020775@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 18:54:58 2010 New Revision: 96432 URL: http://llvm.org/viewvc/llvm-project?rev=96432&view=rev Log: Fold bswap(undef) to undef. Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=96432&r1=96431&r2=96432&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Feb 16 18:54:58 2010 @@ -1179,6 +1179,12 @@ return 0; } + if (isa(Operands[0])) { + if (Name.startswith("llvm.bswap")) + return Operands[0]; + return 0; + } + return 0; } Modified: llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll?rev=96432&r1=96431&r2=96432&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/bswap-fold.ll Tue Feb 16 18:54:58 2010 @@ -67,3 +67,9 @@ %D = tail call i16 @llvm.bswap.i16(i16 %C) nounwind ret i16 %D } + +; Misc: Fold bswap(undef) to undef. +define i64 @foo() { + %a = call i64 @llvm.bswap.i64(i64 undef) + ret i64 %a +} From sabre at nondot.org Tue Feb 16 19:03:10 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 01:03:10 -0000 Subject: [llvm-commits] [llvm] r96433 - in /llvm/trunk/utils/TableGen: DAGISelMatcher.h DAGISelMatcherEmitter.cpp DAGISelMatcherGen.cpp Message-ID: <201002170103.o1H13APZ021227@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 19:03:09 2010 New Revision: 96433 URL: http://llvm.org/viewvc/llvm-project?rev=96433&view=rev Log: improve comments on OPC_Record to say what we're recording a node. Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96433&r1=96432&r2=96433&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Tue Feb 16 19:03:09 2010 @@ -127,8 +127,14 @@ /// RecordMatcherNode - Save the current node in the operand list. class RecordMatcherNode : public MatcherNodeWithChild { + /// WhatFor - This is a string indicating why we're recording this. This + /// should only be used for comment generation not anything semantic. + std::string WhatFor; public: - RecordMatcherNode() : MatcherNodeWithChild(Record) {} + RecordMatcherNode(StringRef whatfor) + : MatcherNodeWithChild(Record), WhatFor(whatfor) {} + + StringRef getWhatFor() const { return WhatFor; } static inline bool classof(const MatcherNode *N) { return N->getKind() == Record; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96433&r1=96432&r2=96433&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Tue Feb 16 19:03:09 2010 @@ -126,7 +126,9 @@ OS.PadToColumn(Indent*2) << "OPC_Emit, /*XXX*/\n\n"; return 1; case MatcherNode::Record: - OS << "OPC_Record,\n"; + OS << "OPC_Record,"; + OS.PadToColumn(CommentIndent) << "// " + << cast(N)->getWhatFor() << '\n'; return 1; case MatcherNode::MoveChild: OS << "OPC_MoveChild, " Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96433&r1=96432&r2=96433&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 19:03:09 2010 @@ -288,7 +288,7 @@ NumRecorded += 2; // Input and output chains. } else { // If it is a normal named node, we must emit a 'Record' opcode. - AddMatcherNode(new RecordMatcherNode()); + AddMatcherNode(new RecordMatcherNode(N->getName())); NumRecorded = 1; } NextRecordedOperandNo += NumRecorded; From gohman at apple.com Tue Feb 16 19:08:57 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 01:08:57 -0000 Subject: [llvm-commits] [llvm] r96434 - /llvm/trunk/test/CodeGen/X86/lsr-overflow.ll Message-ID: <201002170108.o1H18vfx021513@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 19:08:57 2010 New Revision: 96434 URL: http://llvm.org/viewvc/llvm-project?rev=96434&view=rev Log: Don't check for comments, which vary between subtargets. Modified: llvm/trunk/test/CodeGen/X86/lsr-overflow.ll Modified: llvm/trunk/test/CodeGen/X86/lsr-overflow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-overflow.ll?rev=96434&r1=96433&r2=96434&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-overflow.ll (original) +++ llvm/trunk/test/CodeGen/X86/lsr-overflow.ll Tue Feb 16 19:08:57 2010 @@ -3,7 +3,7 @@ ; The comparison uses the pre-inc value, which could lead LSR to ; try to compute -INT64_MIN. -; CHECK: movabsq $-9223372036854775808, %rax ## imm = 0x8000000000000000 +; CHECK: movabsq $-9223372036854775808, %rax ; CHECK: cmpq %rax, %rbx ; CHECK: sete %al From sanjiv.gupta at microchip.com Tue Feb 16 19:11:53 2010 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Wed, 17 Feb 2010 01:11:53 -0000 Subject: [llvm-commits] [llvm] r96435 - in /llvm/trunk/lib/Target/PIC16/PIC16Passes: PIC16Cloner.cpp PIC16Cloner.h Message-ID: <201002170111.o1H1BrHA021646@zion.cs.uiuc.edu> Author: sgupta Date: Tue Feb 16 19:11:53 2010 New Revision: 96435 URL: http://llvm.org/viewvc/llvm-project?rev=96435&view=rev Log: Initial implementation of PIC16 Cloner pass. This pass is supposed to be run on the linked .bc module. It traveses the module call graph twice. Once starting from the main function and marking each reached function as "ML". Again, starting from the ISR and cloning any reachable function that was marked as "ML". After cloning the function, it remaps all the call sites in IL functions to call the cloned functions. Currently only marking is being done. Added: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h Added: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp?rev=96435&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp (added) +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp Tue Feb 16 19:11:53 2010 @@ -0,0 +1,184 @@ +//===-- PIC16Cloner.cpp - PIC16 LLVM Cloner for shared functions -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains code to clone all functions that are shared between +// the main line code (ML) and interrupt line code (IL). It clones all such +// shared functions and their automatic global vars by adding the .IL suffix. +// +// This pass is supposed to be run on the linked .bc module. +// It traveses the module call graph twice. Once starting from the main function +// and marking each reached function as "ML". Again, starting from the ISR +// and cloning any reachable function that was marked as "ML". After cloning +// the function, it remaps all the call sites in IL functions to call the +// cloned functions. +//===----------------------------------------------------------------------===// + +#include "llvm/Analysis/CallGraph.h" +#include "llvm/Pass.h" +#include "llvm/Module.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Transforms/Utils/Cloning.h" +#include "PIC16Cloner.h" +#include "../PIC16ABINames.h" +#include + +using namespace llvm; +using std::vector; +using std::string; +using std::map; + +namespace llvm { + char PIC16Cloner::ID = 0; + + ModulePass *createPIC16ClonerPass() { return new PIC16Cloner(); } +} + +// We currently intend to run these passes in opt, which does not have any +// diagnostic support. So use these functions for now. In future +// we will probably write our own driver tool. +// +void PIC16Cloner::reportError(string ErrorString) { + errs() << "ERROR : " << ErrorString << "\n"; + exit(1); +} + +void PIC16Cloner:: +reportError (string ErrorString, vector &Values) { + unsigned ValCount = Values.size(); + string TargetString; + for (unsigned i=0; i(); + // Initially record that no interrupt has been found + foundISR = false; + + // First mark the MainLine. + for (CallGraph::iterator it = CG.begin() ; it != CG.end(); it++) + { + // External calling node doesn't have any function associated + // with it + if (!it->first) + continue; + + if (it->first->getName().str() == "main") { + // See if the main itself is interrupt function then report an error. + if (PAN::isISR(it->first->getSection())) + reportError("Function 'main' can't be interrupt function"); + else { + // Function main itself is MainLine function. + it->second->getFunction()->setSection("ML"); + // mark the hierarchy + markCallGraph(it->second, "ML"); + // MainLine has been marked now break ; don't search any further. + break; + } + } + } + + // When the MainLine has been marked only then mark the InterruptLine. + for (CallGraph::iterator it = CG.begin() ; it != CG.end(); it++) + { + // External calling node doesn't have any function associated + // with it + if (!it->first) + continue; + + if (PAN::isISR(it->first->getSection())) { + + if (foundISR) + reportError("More than one interrupt functions defined in the module"); + + foundISR = true; + + markCallGraph(it->second, "IL"); + // InterruptLine handled now break; don't search any further. + break; + } + } + + return true; +} + +// For PIC16, automatic variables of a function are emitted as globals. +// Clone the auto variables of a function and put them in ValueMap, +// this ValueMap will be used while +// Cloning the code of function itself. +// +void PIC16Cloner::CloneAutos(Function *F) { + // Not implemented yet. +} + + +// Mark all reachable functions from the given node, with the given mark. +// +void PIC16Cloner::markCallGraph(CallGraphNode *CGN, string StringMark) { + string AlternateMark; + if (StringMark == "ML") + AlternateMark = "IL"; + else + AlternateMark = "ML"; + + // Mark all the called functions + for(CallGraphNode::iterator cgn_it = CGN->begin(); + cgn_it != CGN->end(); ++cgn_it) { + Function *CalledF = cgn_it->second->getFunction(); + + // If calling an external function then CallGraphNode + // will not be associated with any function. + if (!CalledF) + continue; + + // Issue diagnostic if interrupt function is being called. + if (PAN::isISR(CalledF->getSection())) { + vector Values; + Values.push_back(CalledF->getName().str()); + reportError("Interrupt function (%0) can't be called", Values); + } + + // Has already been mark + if (CalledF->getSection().find(StringMark) != string::npos) { + // Should we do anything here? + } else { + // Mark now + if (CalledF->getSection().find(AlternateMark) != string::npos) { + // Function is alternatively marked. It should be a shared one. + // Create IL copy. Passing called function as first argument + // and the caller as the second argument. + + // Before making IL copy, first ensure that this function has a + // body. If the function does have a body. It can't be cloned. + // Such a case may occur when the function has been declarated + // in the C source code but its body exists in assembly file. + if (!CalledF->isDeclaration()) { + // FIXME: Not implemented yet. Clone the function here. + } + } else { + // Function is not marked. It should be marked now. + CalledF->setSection(StringMark); + } + } + // Before going any further mark all the called function by current + // function. + markCallGraph(cgn_it->second ,StringMark); + } // end of loop of all called functions. +} + Added: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h?rev=96435&view=auto ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h (added) +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h Tue Feb 16 19:11:53 2010 @@ -0,0 +1,70 @@ +//===-- PIC16Cloner.h - PIC16 LLVM Cloner for shared functions --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains declaration of a cloner class clone all functions that +// are shared between the main line code (ML) and interrupt line code (IL). +// +//===----------------------------------------------------------------------===// + +#ifndef PIC16CLONER_H +#define PIC16CLONER_H + +#include "llvm/ADT/DenseMap.h" + +using namespace llvm; +using std::vector; +using std::string; +using std::map; + +namespace llvm { + // forward classes. + class Value; + class Function; + class Module; + class ModulePass; + class CallGraph; + class CallGraphNode; + class AnalysisUsage; + + class PIC16Cloner : public ModulePass { + public: + static char ID; // Class identification + PIC16Cloner() : ModulePass(&ID) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + } + virtual bool runOnModule(Module &M); + + private: // Functions + // Mark reachable functions for the MainLine or InterruptLine. + void markCallGraph(CallGraphNode *CGN, string StringMark); + + // Clone auto variables of function specified. + void CloneAutos(Function *F); + + // Error reporting for PIC16Pass + void reportError(string ErrorString, vector &Values); + void reportError(string ErrorString); + + private: //data + // Records if the interrupt function has already been found. + // If more than one interrupt function is found then an error + // should be thrown. + bool foundISR; + + // This ValueMap maps the auto variables of the original functions with + // the corresponding cloned auto variable of the cloned function. + // This value map is passed during the function cloning so that all the + // uses of auto variables be updated properly. + DenseMap ValueMap; + }; +} // End of anonymous namespace + +#endif From sabre at nondot.org Tue Feb 16 19:27:29 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 01:27:29 -0000 Subject: [llvm-commits] [llvm] r96436 - in /llvm/trunk/utils/TableGen: DAGISelMatcher.h DAGISelMatcherGen.cpp Message-ID: <201002170127.o1H1RUrj022483@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 19:27:29 2010 New Revision: 96436 URL: http://llvm.org/viewvc/llvm-project?rev=96436&view=rev Log: prefix captured value names with $ so they look like variables. Use the fancy OpNo variable instead of i, which has the right index including chains. Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96436&r1=96435&r2=96436&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Tue Feb 16 19:27:29 2010 @@ -131,10 +131,10 @@ /// should only be used for comment generation not anything semantic. std::string WhatFor; public: - RecordMatcherNode(StringRef whatfor) + RecordMatcherNode(const std::string &whatfor) : MatcherNodeWithChild(Record), WhatFor(whatfor) {} - StringRef getWhatFor() const { return WhatFor; } + const std::string &getWhatFor() const { return WhatFor; } static inline bool classof(const MatcherNode *N) { return N->getKind() == Record; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96436&r1=96435&r2=96436&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 19:27:29 2010 @@ -249,7 +249,7 @@ for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { // Get the code suitable for matching this child. Move to the child, check // it then move back to the parent. - AddMatcherNode(new MoveChildMatcherNode(i)); + AddMatcherNode(new MoveChildMatcherNode(OpNo)); EmitMatchCode(N->getChild(i), NodeNoTypes->getChild(i)); AddMatcherNode(new MoveParentMatcherNode()); } @@ -267,7 +267,6 @@ InferPossibleTypes(); } - // If this node has a name associated with it, capture it in VariableMap. If // we already saw this in the pattern, emit code to verify dagness. if (!N->getName().empty()) { @@ -288,7 +287,7 @@ NumRecorded += 2; // Input and output chains. } else { // If it is a normal named node, we must emit a 'Record' opcode. - AddMatcherNode(new RecordMatcherNode(N->getName())); + AddMatcherNode(new RecordMatcherNode("$" + N->getName())); NumRecorded = 1; } NextRecordedOperandNo += NumRecorded; From sabre at nondot.org Tue Feb 16 19:34:15 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 01:34:15 -0000 Subject: [llvm-commits] [llvm] r96437 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002170134.o1H1YFQL022861@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 19:34:15 2010 New Revision: 96437 URL: http://llvm.org/viewvc/llvm-project?rev=96437&view=rev Log: record input chains. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96437&r1=96436&r2=96437&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 19:34:15 2010 @@ -194,6 +194,15 @@ // the child numbers of the node are all offset by one. unsigned OpNo = 0; if (N->NodeHasProperty(SDNPHasChain, CGP)) { + // Record the input chain, which is always input #0 of the SDNode. + AddMatcherNode(new MoveChildMatcherNode(0)); + ++NextRecordedOperandNo; + AddMatcherNode(new RecordMatcherNode("'" + N->getOperator()->getName() + + "' input chain")); + AddMatcherNode(new MoveParentMatcherNode()); + + // Don't look at the input chain when matching the tree pattern to the + // SDNode. OpNo = 1; // If this node is not the root and the subtree underneath it produces a From sabre at nondot.org Tue Feb 16 19:38:01 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 01:38:01 -0000 Subject: [llvm-commits] [llvm] r96438 - /llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Message-ID: <201002170138.o1H1c15v023131@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 19:38:01 2010 New Revision: 96438 URL: http://llvm.org/viewvc/llvm-project?rev=96438&view=rev Log: add a comment explaining why darwin/i386 uses ## as a comment. It's not clear why this is really required, but it was explicitly added in r48808 with no real explanation or rdar #. Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=96438&r1=96437&r2=96438&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Tue Feb 16 19:38:01 2010 @@ -55,6 +55,8 @@ if (!is64Bit) Data64bitsDirective = 0; // we can't emit a 64-bit unit + // Use ## as a comment string so that .s files generated by llvm can go + // through the GCC preprocessor without causing an error. CommentString = "##"; PCSymbol = "."; From sabre at nondot.org Tue Feb 16 19:55:54 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 01:55:54 -0000 Subject: [llvm-commits] [llvm] r96440 - /llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Message-ID: <201002170155.o1H1tssD024028@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 19:55:54 2010 New Revision: 96440 URL: http://llvm.org/viewvc/llvm-project?rev=96440&view=rev Log: daniel remembered why this was needed. Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=96440&r1=96439&r2=96440&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Tue Feb 16 19:55:54 2010 @@ -56,7 +56,10 @@ Data64bitsDirective = 0; // we can't emit a 64-bit unit // Use ## as a comment string so that .s files generated by llvm can go - // through the GCC preprocessor without causing an error. + // through the GCC preprocessor without causing an error. This is needed + // because "clang foo.s" runs the C preprocessor, which is usually reserved + // for .S files on other systems. Perhaps this is because the file system + // wasn't always case preserving or something. CommentString = "##"; PCSymbol = "."; From sabre at nondot.org Tue Feb 16 20:16:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 02:16:19 -0000 Subject: [llvm-commits] [llvm] r96443 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002170216.o1H2GJe9024931@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 20:16:19 2010 New Revision: 96443 URL: http://llvm.org/viewvc/llvm-project?rev=96443&view=rev Log: Prep work to handle input chains of matched patterns and checking for 'ischaincompatible' when a pattern has more than one input chain. Need to do some commenting and cleanup now that I understand how this works. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96443&r1=96442&r2=96443&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Feb 16 20:16:19 2010 @@ -10,6 +10,7 @@ #include "DAGISelMatcher.h" #include "CodeGenDAGPatterns.h" #include "Record.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" using namespace llvm; @@ -29,7 +30,15 @@ StringMap VariableMap; unsigned NextRecordedOperandNo; + /// InputChains - This maintains the position in the recorded nodes array of + /// all of the recorded input chains. + SmallVector InputChains; + + /// Matcher - This is the top level of the generated matcher, the result. MatcherNodeWithChild *Matcher; + + /// CurPredicate - As we emit matcher nodes, this points to the latest check + /// which should have future checks stuck into its child position. MatcherNodeWithChild *CurPredicate; public: MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp); @@ -194,13 +203,30 @@ // the child numbers of the node are all offset by one. unsigned OpNo = 0; if (N->NodeHasProperty(SDNPHasChain, CGP)) { + // FIXME: Not correct for complex patterns, they need to push their own + // *matched* input chain. + // Record the input chain, which is always input #0 of the SDNode. AddMatcherNode(new MoveChildMatcherNode(0)); - ++NextRecordedOperandNo; AddMatcherNode(new RecordMatcherNode("'" + N->getOperator()->getName() + "' input chain")); + + // Remember all of the input chains our pattern will match. + InputChains.push_back(NextRecordedOperandNo); + ++NextRecordedOperandNo; AddMatcherNode(new MoveParentMatcherNode()); - + + // If this is the second (e.g. indbr(load) or store(add(load))) or third + // input chain (e.g. (store (add (load, load))) from msp430) we need to make + // sure that folding the chain won't induce cycles in the DAG. This could + // happen if there were an intermediate node between the indbr and load, for + // example. + + // FIXME: Emit "lastchain.getNode() == CurrentNode || + // IsChainCompatible(lastchain.getNode(), CurrentNode)". + // Rename IsChainCompatible -> IsChainUnreachable, add comment about + // complexity. + // Don't look at the input chain when matching the tree pattern to the // SDNode. OpNo = 1; @@ -252,8 +278,6 @@ AddMatcherNode(new CheckFoldableChainNodeMatcherNode()); } } - - // FIXME: Need to generate IsChainCompatible checks. for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { // Get the code suitable for matching this child. Move to the child, check From dpatel at apple.com Tue Feb 16 20:20:35 2010 From: dpatel at apple.com (Devang Patel) Date: Wed, 17 Feb 2010 02:20:35 -0000 Subject: [llvm-commits] [llvm] r96445 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/FrontendC/2010-02-16-DbgVarScope.c Message-ID: <201002170220.o1H2KZki025225@zion.cs.uiuc.edu> Author: dpatel Date: Tue Feb 16 20:20:34 2010 New Revision: 96445 URL: http://llvm.org/viewvc/llvm-project?rev=96445&view=rev Log: Before setting scope end marker, pay attention to scope begin marker and existing scope end marker, if any. Scope must begin before it ends and nested inlined scope do not truncate surrounding scope. Added: llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=96445&r1=96444&r2=96445&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Feb 16 20:20:34 2010 @@ -238,7 +238,18 @@ LIndex = DSI; } } - setLastInsn(LastInsn); + + unsigned CurrentLastInsnIndex = 0; + if (const MachineInstr *CL = getLastInsn()) + CurrentLastInsnIndex = MIIndexMap[CL]; + unsigned FIndex = MIIndexMap[getFirstInsn()]; + + // Set LastInsn as the last instruction for this scope only if + // it follows + // 1) this scope's first instruction and + // 2) current last instruction for this scope, if any. + if (LIndex >= CurrentLastInsnIndex && LIndex >= FIndex) + setLastInsn(LastInsn); } #ifndef NDEBUG Added: llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c?rev=96445&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c (added) +++ llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c Tue Feb 16 20:20:34 2010 @@ -0,0 +1,30 @@ +// RUN: %llvmgcc -S -O0 -g %s -o - | \ +// RUN: llc --disable-fp-elim -o %t.s -O0 -relocation-model=pic +// RUN: %compile_c %t.s -o %t.o +// RUN: %link %t.o -o %t.exe +// RUN: echo {break 24\nrun\np loc\n} > %t.in +// RN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \ +// RN: grep {$1 = 1} + +int g1 = 1; +int g2 = 2; + +int __attribute__((always_inline)) bar() { + return g2 - g1; +} +void foobar() {} + +void foo(int s) { + unsigned loc = 0; + if (s) { + loc = 1; + foobar(); + } else { + loc = bar(); + foobar(); + } +} + +int main() { + foo(0); +} From gohman at apple.com Tue Feb 16 20:39:31 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 02:39:31 -0000 Subject: [llvm-commits] [llvm] r96448 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <201002170239.o1H2dVW1026176@zion.cs.uiuc.edu> Author: djg Date: Tue Feb 16 20:39:31 2010 New Revision: 96448 URL: http://llvm.org/viewvc/llvm-project?rev=96448&view=rev Log: Fix SCEVExpander's existing PHI reuse checking to recognize the case where there are loop-invariant instructions somehow left inside the loop, and in a position where they won't dominate the IV increment position. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=96448&r1=96447&r2=96448&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Tue Feb 16 20:39:31 2010 @@ -658,6 +658,19 @@ IncV = 0; break; } + // If any of the operands don't dominate the insert position, bail. + // Addrec operands are always loop-invariant, so this can only happen + // if there are instructions which haven't been hoisted. + for (User::op_iterator OI = IncV->op_begin()+1, + OE = IncV->op_end(); OI != OE; ++OI) + if (Instruction *OInst = dyn_cast(OI)) + if (!SE.DT->dominates(OInst, IVIncInsertPos)) { + IncV = 0; + break; + } + if (!IncV) + break; + // Advance to the next instruction. IncV = dyn_cast(IncV->getOperand(0)); if (!IncV) break; From lhames at gmail.com Tue Feb 16 21:42:51 2010 From: lhames at gmail.com (Lang Hames) Date: Wed, 17 Feb 2010 03:42:51 -0000 Subject: [llvm-commits] [llvm] r96450 - /llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Message-ID: <201002170342.o1H3gpcS028883@zion.cs.uiuc.edu> Author: lhames Date: Tue Feb 16 21:42:51 2010 New Revision: 96450 URL: http://llvm.org/viewvc/llvm-project?rev=96450&view=rev Log: Removed an early out which was causing the PBQP allocator to not compute live-in sets or run the rewriter. Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=96450&r1=96449&r2=96450&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Tue Feb 16 21:42:51 2010 @@ -867,10 +867,6 @@ // Find the vreg intervals in need of allocation. findVRegIntervalsToAlloc(); - // If there aren't any then we're done here. - if (vregIntervalsToAlloc.empty() && emptyVRegIntervals.empty()) - return true; - // If there are non-empty intervals allocate them using pbqp. if (!vregIntervalsToAlloc.empty()) { From sabre at nondot.org Tue Feb 16 23:35:38 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 05:35:38 -0000 Subject: [llvm-commits] [llvm] r96453 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002170535.o1H5Zjag001281@zion.cs.uiuc.edu> Author: lattner Date: Tue Feb 16 23:35:28 2010 New Revision: 96453 URL: http://llvm.org/viewvc/llvm-project?rev=96453&view=rev Log: simplify IsChainCompatible codegen, add comments. no functionality change. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96453&r1=96452&r2=96453&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Tue Feb 16 23:35:28 2010 @@ -26,9 +26,8 @@ /// node list. SelectionDAG::allnodes_iterator ISelPosition; -/// IsChainCompatible - Returns true if Chain is Op or Chain does -/// not reach Op. -static bool IsChainCompatible(SDNode *Chain, SDNode *Op) { +/// ChainNotReachable - Returns true if Chain does not reach Op. +static bool ChainNotReachable(SDNode *Chain, SDNode *Op) { if (Chain->getOpcode() == ISD::EntryToken) return true; if (Chain->getOpcode() == ISD::TokenFactor) @@ -36,11 +35,20 @@ if (Chain->getNumOperands() > 0) { SDValue C0 = Chain->getOperand(0); if (C0.getValueType() == MVT::Other) - return C0.getNode() != Op && IsChainCompatible(C0.getNode(), Op); + return C0.getNode() != Op && ChainNotReachable(C0.getNode(), Op); } return true; } +/// IsChainCompatible - Returns true if Chain is Op or Chain does not reach Op. +/// This is used to ensure that there are no nodes trapped between Chain, which +/// is the first chain node discovered in a pattern and Op, a later node, that +/// will not be selected into the pattern. +static bool IsChainCompatible(SDNode *Chain, SDNode *Op) { + return Chain == Op || ChainNotReachable(Chain, Op); +} + + /// ISelUpdater - helper class to handle updates of the /// instruciton selection graph. class VISIBILITY_HIDDEN ISelUpdater : public SelectionDAG::DAGUpdateListener { Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96453&r1=96452&r2=96453&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Tue Feb 16 23:35:28 2010 @@ -606,10 +606,8 @@ if (NodeHasChain) { if (FoundChain) { - emitCheck("(" + ChainName + ".getNode() == " + - getNodeName(RootName) + " || " - "IsChainCompatible(" + ChainName + ".getNode(), " + - getNodeName(RootName) + "))"); + emitCheck("IsChainCompatible(" + ChainName + ".getNode(), " + + getNodeName(RootName) + ")"); OrigChains.push_back(std::make_pair(ChainName, getValueName(RootName))); } else From asl at math.spbu.ru Tue Feb 16 23:53:11 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Wed, 17 Feb 2010 05:53:11 -0000 Subject: [llvm-commits] [llvm] r96454 - /llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Message-ID: <201002170553.o1H5rCvf002007@zion.cs.uiuc.edu> Author: asl Date: Tue Feb 16 23:53:11 2010 New Revision: 96454 URL: http://llvm.org/viewvc/llvm-project?rev=96454&view=rev Log: Use pointer-wide encoding for LSDA and FDE on Darwin. Hopefully, this will fix the remaining issues seen there. Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=96454&r1=96453&r2=96454&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Tue Feb 16 23:53:11 2010 @@ -154,11 +154,11 @@ } unsigned X8632_MachoTargetObjectFile::getLSDAEncoding() const { - return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + return DW_EH_PE_pcrel; } unsigned X8632_MachoTargetObjectFile::getFDEEncoding() const { - return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + return DW_EH_PE_pcrel; } unsigned X8632_MachoTargetObjectFile::getTTypeEncoding() const { @@ -170,11 +170,11 @@ } unsigned X8664_MachoTargetObjectFile::getLSDAEncoding() const { - return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + return DW_EH_PE_pcrel; } unsigned X8664_MachoTargetObjectFile::getFDEEncoding() const { - return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + return DW_EH_PE_pcrel; } unsigned X8664_MachoTargetObjectFile::getTTypeEncoding() const { From sabre at nondot.org Wed Feb 17 00:07:47 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 06:07:47 -0000 Subject: [llvm-commits] [llvm] r96456 - /llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Message-ID: <201002170607.o1H67ll3002663@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 00:07:47 2010 New Revision: 96456 URL: http://llvm.org/viewvc/llvm-project?rev=96456&view=rev Log: rename and document some arguments so I don't have to keep reverse engineering what they are. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=96456&r1=96455&r2=96456&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed Feb 17 00:07:47 2010 @@ -213,7 +213,8 @@ SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, SDValue &Segment, - SDValue &InChain, SDValue &OutChain); + SDValue &PatternChainResult, + SDValue &PatternInputChain); bool TryFoldLoad(SDNode *P, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, @@ -1317,22 +1318,28 @@ /// SelectScalarSSELoad - Match a scalar SSE load. In particular, we want to /// match a load whose top elements are either undef or zeros. The load flavor /// is derived from the type of N, which is either v4f32 or v2f64. +/// +/// We also return: +/// PatternInputChain: this is the chain node input to the pattern that the +/// newly selected instruction should use. +/// PatternChainResult: this is chain result matched by the pattern which +/// should be replaced with the chain result of the matched node. bool X86DAGToDAGISel::SelectScalarSSELoad(SDNode *Root, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, SDValue &Segment, - SDValue &InChain, - SDValue &OutChain) { + SDValue &PatternChainResult, + SDValue &PatternInputChain) { if (N.getOpcode() == ISD::SCALAR_TO_VECTOR) { - InChain = N.getOperand(0).getValue(1); - if (ISD::isNON_EXTLoad(InChain.getNode()) && - InChain.getValue(0).hasOneUse() && - IsProfitableToFold(N.getOperand(0), InChain.getNode(), Root) && + PatternChainResult = N.getOperand(0).getValue(1); + if (ISD::isNON_EXTLoad(PatternChainResult.getNode()) && + PatternChainResult.getValue(0).hasOneUse() && + IsProfitableToFold(N.getOperand(0),PatternChainResult.getNode(),Root) && IsLegalToFold(N.getOperand(0), N.getNode(), Root)) { - LoadSDNode *LD = cast(InChain); + LoadSDNode *LD = cast(PatternChainResult); if (!SelectAddr(Root, LD->getBasePtr(), Base, Scale, Index, Disp,Segment)) return false; - OutChain = LD->getChain(); + PatternInputChain = LD->getChain(); return true; } } @@ -1351,8 +1358,8 @@ LoadSDNode *LD = cast(N.getOperand(0).getOperand(0)); if (!SelectAddr(Root, LD->getBasePtr(), Base, Scale, Index, Disp, Segment)) return false; - OutChain = LD->getChain(); - InChain = SDValue(LD, 1); + PatternInputChain = LD->getChain(); + PatternChainResult = SDValue(LD, 1); return true; } return false; From sabre at nondot.org Wed Feb 17 00:08:25 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 06:08:25 -0000 Subject: [llvm-commits] [llvm] r96457 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002170608.o1H68PUm002706@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 00:08:25 2010 New Revision: 96457 URL: http://llvm.org/viewvc/llvm-project?rev=96457&view=rev Log: properly record chain inputs to complex patterns, resolving a fixme. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96457&r1=96456&r2=96457&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Wed Feb 17 00:08:25 2010 @@ -155,7 +155,18 @@ // Handle complex pattern. const ComplexPattern &CP = CGP.getComplexPattern(LeafRec); - return AddMatcherNode(new CheckComplexPatMatcherNode(CP)); + AddMatcherNode(new CheckComplexPatMatcherNode(CP)); + + // If the complex pattern has a chain, then we need to keep track of the + // fact that we just recorded a chain input. The chain input will be + // matched as the last operand of the predicate if it was successful. + if (CP.hasProperty(SDNPHasChain)) { + // It is the last operand recorded. + assert(NextRecordedOperandNo > 1 && + "Should have recorded input/result chains at least!"); + InputChains.push_back(NextRecordedOperandNo-1); + } + return; } errs() << "Unknown leaf kind: " << *N << "\n"; @@ -203,9 +214,6 @@ // the child numbers of the node are all offset by one. unsigned OpNo = 0; if (N->NodeHasProperty(SDNPHasChain, CGP)) { - // FIXME: Not correct for complex patterns, they need to push their own - // *matched* input chain. - // Record the input chain, which is always input #0 of the SDNode. AddMatcherNode(new MoveChildMatcherNode(0)); AddMatcherNode(new RecordMatcherNode("'" + N->getOperator()->getName() + @@ -222,8 +230,7 @@ // happen if there were an intermediate node between the indbr and load, for // example. - // FIXME: Emit "lastchain.getNode() == CurrentNode || - // IsChainCompatible(lastchain.getNode(), CurrentNode)". + // FIXME: Emit "IsChainCompatible(lastchain.getNode(), CurrentNode)". // Rename IsChainCompatible -> IsChainUnreachable, add comment about // complexity. From sabre at nondot.org Wed Feb 17 00:23:40 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 06:23:40 -0000 Subject: [llvm-commits] [llvm] r96458 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002170623.o1H6NeSG003321@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 00:23:39 2010 New Revision: 96458 URL: http://llvm.org/viewvc/llvm-project?rev=96458&view=rev Log: Emulate the current isel's "IsChainCompatible" logic for now. I'd like to eventually rip it out, but for now producing the same selections as the old matcher is more important. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/utils/TableGen/DAGISelMatcher.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96458&r1=96457&r2=96458&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Wed Feb 17 00:23:39 2010 @@ -217,7 +217,8 @@ OPC_CheckComplexPat, OPC_CheckAndImm1, OPC_CheckAndImm2, OPC_CheckAndImm4, OPC_CheckAndImm8, OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8, - OPC_CheckFoldableChainNode + OPC_CheckFoldableChainNode, + OPC_CheckChainCompatible }; struct MatchScope { @@ -409,6 +410,13 @@ continue; } + case OPC_CheckChainCompatible: { + unsigned PrevNode = MatcherTable[MatcherIndex++]; + assert(PrevNode < RecordedNodes.size() && "Invalid CheckChainCompatible"); + if (!IsChainCompatible(RecordedNodes[PrevNode].getNode(), N.getNode())) + break; + continue; + } } // If the code reached this point, then the match failed pop out to the next Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96458&r1=96457&r2=96458&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Wed Feb 17 00:23:39 2010 @@ -111,3 +111,9 @@ OS.indent(indent) << "CheckFoldableChainNode\n"; printChild(OS, indent); } + +void CheckChainCompatibleMatcherNode::print(raw_ostream &OS, + unsigned indent) const { + OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n"; + printChild(OS, indent); +} Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96458&r1=96457&r2=96458&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Wed Feb 17 00:23:39 2010 @@ -50,7 +50,8 @@ CheckComplexPat, CheckAndImm, CheckOrImm, - CheckFoldableChainNode + CheckFoldableChainNode, + CheckChainCompatible }; const KindTy Kind; @@ -380,6 +381,25 @@ virtual void print(raw_ostream &OS, unsigned indent = 0) const; }; +/// CheckChainCompatibleMatcherNode - Verify that the current node's chain +/// operand is 'compatible' with the specified recorded node's. +class CheckChainCompatibleMatcherNode : public MatcherNodeWithChild { + unsigned PreviousOp; +public: + CheckChainCompatibleMatcherNode(unsigned previousop) + : MatcherNodeWithChild(CheckChainCompatible), PreviousOp(previousop) {} + + unsigned getPreviousOp() const { return PreviousOp; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == CheckChainCompatible; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + + + } // end namespace llvm #endif Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96458&r1=96457&r2=96458&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Wed Feb 17 00:23:39 2010 @@ -204,6 +204,10 @@ case MatcherNode::CheckFoldableChainNode: OS << "OPC_CheckFoldableChainNode,\n"; return 1; + case MatcherNode::CheckChainCompatible: + OS << "OPC_CheckChainCompatible, " + << cast(N)->getPreviousOp() << ",\n"; + return 2; } assert(0 && "Unreachable"); return 0; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96458&r1=96457&r2=96458&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Wed Feb 17 00:23:39 2010 @@ -165,6 +165,16 @@ assert(NextRecordedOperandNo > 1 && "Should have recorded input/result chains at least!"); InputChains.push_back(NextRecordedOperandNo-1); + + // IF we need to check chains, do so, see comment for + // "NodeHasProperty(SDNPHasChain" below. + if (InputChains.size() > 1) { + // FIXME: This is broken, we should eliminate this nonsense completely, + // but we want to produce the same selections that the old matcher does + // for now. + unsigned PrevOp = InputChains[InputChains.size()-2]; + AddMatcherNode(new CheckChainCompatibleMatcherNode(PrevOp)); + } } return; } @@ -229,10 +239,13 @@ // sure that folding the chain won't induce cycles in the DAG. This could // happen if there were an intermediate node between the indbr and load, for // example. - - // FIXME: Emit "IsChainCompatible(lastchain.getNode(), CurrentNode)". - // Rename IsChainCompatible -> IsChainUnreachable, add comment about - // complexity. + if (InputChains.size() > 1) { + // FIXME: This is broken, we should eliminate this nonsense completely, + // but we want to produce the same selections that the old matcher does + // for now. + unsigned PrevOp = InputChains[InputChains.size()-2]; + AddMatcherNode(new CheckChainCompatibleMatcherNode(PrevOp)); + } // Don't look at the input chain when matching the tree pattern to the // SDNode. From sabre at nondot.org Wed Feb 17 00:28:22 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 06:28:22 -0000 Subject: [llvm-commits] [llvm] r96460 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002170628.o1H6SMF2003529@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 00:28:22 2010 New Revision: 96460 URL: http://llvm.org/viewvc/llvm-project?rev=96460&view=rev Log: sink special case "cannotyetselect" for intrinsics out of the tblgen splatted code into the implementation. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=96460&r1=96459&r2=96460&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Feb 17 00:28:22 2010 @@ -1444,6 +1444,11 @@ } void SelectionDAGISel::CannotYetSelect(SDNode *N) { + if (N->getOpcode() == ISD::INTRINSIC_W_CHAIN || + N->getOpcode() == ISD::INTRINSIC_WO_CHAIN || + N->getOpcode() == ISD::INTRINSIC_VOID) + return CannotYetSelectIntrinsic(N); + std::string msg; raw_string_ostream Msg(msg); Msg << "Cannot yet select: "; Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96460&r1=96459&r2=96460&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Feb 17 00:28:22 2010 @@ -1841,13 +1841,7 @@ // catch the case where nothing handles a pattern. if (mightNotMatch) { OS << "\n"; - if (OpName != "ISD::INTRINSIC_W_CHAIN" && - OpName != "ISD::INTRINSIC_WO_CHAIN" && - OpName != "ISD::INTRINSIC_VOID") - OS << " CannotYetSelect(N);\n"; - else - OS << " CannotYetSelectIntrinsic(N);\n"; - + OS << " CannotYetSelect(N);\n"; OS << " return NULL;\n"; } OS << "}\n\n"; @@ -1948,13 +1942,7 @@ } OS << " } // end of big switch.\n\n" - << " if (N->getOpcode() != ISD::INTRINSIC_W_CHAIN &&\n" - << " N->getOpcode() != ISD::INTRINSIC_WO_CHAIN &&\n" - << " N->getOpcode() != ISD::INTRINSIC_VOID) {\n" - << " CannotYetSelect(N);\n" - << " } else {\n" - << " CannotYetSelectIntrinsic(N);\n" - << " }\n" + << " CannotYetSelect(N);\n" << " return NULL;\n" << "}\n\n"; } From johnny.chen at apple.com Wed Feb 17 00:31:49 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 17 Feb 2010 06:31:49 -0000 Subject: [llvm-commits] [llvm] r96462 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002170631.o1H6VnWN003745@zion.cs.uiuc.edu> Author: johnny Date: Wed Feb 17 00:31:48 2010 New Revision: 96462 URL: http://llvm.org/viewvc/llvm-project?rev=96462&view=rev Log: Added BFI for disassembly only. A8.6.18 BFI - Bitfield insert (Encoding A1) Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96462&r1=96461&r2=96462&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Feb 17 00:31:48 2010 @@ -1443,6 +1443,17 @@ let Inst{6-0} = 0b0011111; } +// A8.6.18 BFI - Bitfield insert (Encoding A1) +// Added for disassembler with the pattern field purposely left blank. +def BFI : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), + AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, + "bfi", "\t$dst, $src, $imm", "", + [/* For disassembly only; pattern left blank */]>, + Requires<[IsARM, HasV6T2]> { + let Inst{27-21} = 0b0111110; + let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15 +} + def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, "mvn", "\t$dst, $src", [(set GPR:$dst, (not GPR:$src))]>, UnaryDP { From sanjiv.gupta at microchip.com Wed Feb 17 00:46:24 2010 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Wed, 17 Feb 2010 06:46:24 -0000 Subject: [llvm-commits] [llvm] r96463 - in /llvm/trunk/lib/Target/PIC16/PIC16Passes: PIC16Overlay.cpp PIC16Overlay.h Message-ID: <201002170646.o1H6kO8o004461@zion.cs.uiuc.edu> Author: sgupta Date: Wed Feb 17 00:46:23 2010 New Revision: 96463 URL: http://llvm.org/viewvc/llvm-project?rev=96463&view=rev Log: Removed header files from .h by adding forward decls. Renamed PIC16FrameOverlay namespace to PIC16OVERLAY. Renamed PIC16FrameOverlay class to PIC16Overlay. Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.cpp llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.h Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.cpp?rev=96463&r1=96462&r2=96463&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.cpp Wed Feb 17 00:46:23 2010 @@ -24,27 +24,27 @@ using namespace llvm; namespace llvm { - char PIC16FrameOverlay::ID = 0; - ModulePass *createPIC16OverlayPass() { return new PIC16FrameOverlay(); } + char PIC16Overlay::ID = 0; + ModulePass *createPIC16OverlayPass() { return new PIC16Overlay(); } } -void PIC16FrameOverlay::getAnalysisUsage(AnalysisUsage &AU) const { +void PIC16Overlay::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired(); } -void PIC16FrameOverlay::DFSTraverse(CallGraphNode *CGN, unsigned Depth) { +void PIC16Overlay::DFSTraverse(CallGraphNode *CGN, unsigned Depth) { // Do not set any color for external calling node. if (Depth != 0 && CGN->getFunction()) { unsigned Color = getColor(CGN->getFunction()); // Handle indirectly called functions - if (Color >= PIC16Overlay::StartIndirectCallColor || - Depth >= PIC16Overlay::StartIndirectCallColor) { + if (Color >= PIC16OVERLAY::StartIndirectCallColor || + Depth >= PIC16OVERLAY::StartIndirectCallColor) { // All functions called from an indirectly called function are given // an unique color. - if (Color < PIC16Overlay::StartIndirectCallColor && - Depth >= PIC16Overlay::StartIndirectCallColor) + if (Color < PIC16OVERLAY::StartIndirectCallColor && + Depth >= PIC16OVERLAY::StartIndirectCallColor) setColor(CGN->getFunction(), Depth); for (unsigned int i = 0; i < CGN->size(); i++) @@ -65,7 +65,7 @@ DFSTraverse((*CGN)[i], Depth+1); } -unsigned PIC16FrameOverlay::ModifyDepthForInterrupt(CallGraphNode *CGN, +unsigned PIC16Overlay::ModifyDepthForInterrupt(CallGraphNode *CGN, unsigned Depth) { Function *Fn = CGN->getFunction(); @@ -81,7 +81,7 @@ return Depth; } -void PIC16FrameOverlay::setColor(Function *Fn, unsigned Color) { +void PIC16Overlay::setColor(Function *Fn, unsigned Color) { std::string Section = ""; if (Fn->hasSection()) Section = Fn->getSection(); @@ -119,7 +119,7 @@ Fn->setSection(Section); } -unsigned PIC16FrameOverlay::getColor(Function *Fn) { +unsigned PIC16Overlay::getColor(Function *Fn) { int Color = 0; if (!Fn->hasSection()) return 0; @@ -150,7 +150,7 @@ return Color; } -bool PIC16FrameOverlay::runOnModule(Module &M) { +bool PIC16Overlay::runOnModule(Module &M) { CallGraph &CG = getAnalysis(); CallGraphNode *ECN = CG.getExternalCallingNode(); @@ -164,7 +164,7 @@ return false; } -void PIC16FrameOverlay::MarkIndirectlyCalledFunctions(Module &M) { +void PIC16Overlay::MarkIndirectlyCalledFunctions(Module &M) { // If the use of a function is not a call instruction then this // function might be called indirectly. In that case give it // an unique color. Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.h?rev=96463&r1=96462&r2=96463&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Overlay.h Wed Feb 17 00:46:23 2010 @@ -1,4 +1,4 @@ -//===-- PIC16FrameOverlay.h - Interface for PIC16 Frame Overlay -*- C++ -*-===// +//===-- PIC16Overlay.h - Interface for PIC16 Frame Overlay -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,30 +14,35 @@ #ifndef PIC16FRAMEOVERLAY_H #define PIC16FRAMEOVERLAY_H -#include "llvm/Analysis/CallGraph.h" -#include "llvm/Pass.h" -#include "llvm/CallGraphSCCPass.h" using std::string; using namespace llvm; namespace llvm { - namespace PIC16Overlay { + // Forward declarations. + class Function; + class Module; + class ModulePass; + class AnalysisUsage; + class CallGraphNode; + class CallGraph; + + namespace PIC16OVERLAY { enum OverlayConsts { StartInterruptColor = 200, StartIndirectCallColor = 300 }; } - class PIC16FrameOverlay : public ModulePass { + class PIC16Overlay : public ModulePass { std::string OverlayStr; unsigned InterruptDepth; unsigned IndirectCallColor; public: static char ID; // Class identification - PIC16FrameOverlay() : ModulePass(&ID) { + PIC16Overlay() : ModulePass(&ID) { OverlayStr = "Overlay="; - InterruptDepth = PIC16Overlay::StartInterruptColor; - IndirectCallColor = PIC16Overlay::StartIndirectCallColor; + InterruptDepth = PIC16OVERLAY::StartInterruptColor; + IndirectCallColor = PIC16OVERLAY::StartIndirectCallColor; } virtual void getAnalysisUsage(AnalysisUsage &AU) const; From sabre at nondot.org Wed Feb 17 00:47:35 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 06:47:35 -0000 Subject: [llvm-commits] [llvm] r96464 - /llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Message-ID: <201002170647.o1H6lZdA004514@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 00:47:35 2010 New Revision: 96464 URL: http://llvm.org/viewvc/llvm-project?rev=96464&view=rev Log: improve comments, the matcher is now feature complete, on to codegen. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96464&r1=96463&r2=96464&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Wed Feb 17 00:47:35 2010 @@ -186,7 +186,11 @@ const ComplexPattern &Pattern = cast(N)->getPattern(); OS << "OPC_CheckComplexPat, " << getComplexPat(Pattern) << ','; - OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc() << '\n'; + OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc(); + OS << ": " << Pattern.getNumOperands() << " operands"; + if (Pattern.hasProperty(SDNPHasChain)) + OS << " + chain result and input"; + OS << '\n'; return 2; } From sanjiv.gupta at microchip.com Wed Feb 17 00:48:50 2010 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Wed, 17 Feb 2010 06:48:50 -0000 Subject: [llvm-commits] [llvm] r96465 - in /llvm/trunk/lib/Target/PIC16: PIC16ABINames.h PIC16Passes/PIC16Cloner.cpp Message-ID: <201002170648.o1H6mpNX004563@zion.cs.uiuc.edu> Author: sgupta Date: Wed Feb 17 00:48:50 2010 New Revision: 96465 URL: http://llvm.org/viewvc/llvm-project?rev=96465&view=rev Log: Added a function to clone locals of a function.( which for pic16 are globals with mangled names). Modified: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16ABINames.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ABINames.h?rev=96465&r1=96464&r2=96465&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ABINames.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ABINames.h Wed Feb 17 00:48:50 2010 @@ -338,6 +338,22 @@ inline static std::string getISRAddr(void) { return "0x4"; } + + // Returns the name of clone of a function. + static std::string getCloneFnName(const std::string &Func) { + return (Func + ".IL"); + } + + // Returns the name of clone of a variable. + static std::string getCloneVarName(const std::string &Fn, + const std::string &Var) { + std::string cloneVarName = Var; + // These vars are named like fun.auto.var. + // Just replace the function name, with clone function name. + std::string cloneFnName = getCloneFnName(Fn); + cloneVarName.replace(cloneVarName.find(Fn), Fn.length(), cloneFnName); + return cloneVarName; + } }; // class PAN. } // end namespace llvm; Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp?rev=96465&r1=96464&r2=96465&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp Wed Feb 17 00:48:50 2010 @@ -124,7 +124,37 @@ // Cloning the code of function itself. // void PIC16Cloner::CloneAutos(Function *F) { - // Not implemented yet. + // We'll need to update module's globals list as well. So keep a reference + // handy. + Module *M = F->getParent(); + Module::GlobalListType &Globals = M->getGlobalList(); + + // Clear the leftovers in ValueMap by any previous cloning. + ValueMap.clear(); + + // Find the auto globls for this function and clone them, and put them + // in ValueMap. + std::string FnName = F->getName().str(); + std::string VarName, ClonedVarName; + for (Module::global_iterator I = M->global_begin(), E = M->global_end(); + I != E; ++I) { + VarName = I->getName().str(); + if (PAN::isLocalToFunc(FnName, VarName)) { + // Auto variable for current function found. Clone it. + GlobalVariable *GV = I; + + const Type *InitTy = GV->getInitializer()->getType(); + GlobalVariable *ClonedGV = + new GlobalVariable(InitTy, false, GV->getLinkage(), + GV->getInitializer()); + ClonedGV->setName(PAN::getCloneVarName(FnName, VarName)); + // Add these new globals to module's globals list. + Globals.push_back(ClonedGV); + + // Update ValueMap. + ValueMap[GV] = ClonedGV; + } + } } From sabre at nondot.org Wed Feb 17 00:53:36 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 06:53:36 -0000 Subject: [llvm-commits] [llvm] r96466 - /llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Message-ID: <201002170653.o1H6ra6S004752@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 00:53:36 2010 New Revision: 96466 URL: http://llvm.org/viewvc/llvm-project?rev=96466&view=rev Log: reduce nesting. Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=96466&r1=96465&r2=96466&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Wed Feb 17 00:53:36 2010 @@ -1648,7 +1648,9 @@ if (!isUse && Pat->getTransformFn()) I->error("Cannot specify a transform function for a non-input value!"); return; - } else if (Pat->getOperator()->getName() == "implicit") { + } + + if (Pat->getOperator()->getName() == "implicit") { for (unsigned i = 0, e = Pat->getNumChildren(); i != e; ++i) { TreePatternNode *Dest = Pat->getChild(i); if (!Dest->isLeaf()) @@ -1660,7 +1662,9 @@ InstImpResults.push_back(Val->getDef()); } return; - } else if (Pat->getOperator()->getName() != "set") { + } + + if (Pat->getOperator()->getName() != "set") { // If this is not a set, verify that the children nodes are not void typed, // and recurse. for (unsigned i = 0, e = Pat->getNumChildren(); i != e; ++i) { @@ -1677,7 +1681,7 @@ if (!isUse && Pat->getTransformFn()) I->error("Cannot specify a transform function for a non-input value!"); return; - } + } // Otherwise, this is a set, validate and collect instruction results. if (Pat->getNumChildren() == 0) From echristo at apple.com Wed Feb 17 01:44:58 2010 From: echristo at apple.com (Eric Christopher) Date: Wed, 17 Feb 2010 07:44:58 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96467 - /llvm-gcc-4.2/trunk/gcc/varasm.c Message-ID: <201002170744.o1H7iw8D006975@zion.cs.uiuc.edu> Author: echristo Date: Wed Feb 17 01:44:58 2010 New Revision: 96467 URL: http://llvm.org/viewvc/llvm-project?rev=96467&view=rev Log: Revert for now: r95604 | dpatel | 2010-02-08 15:26:53 -0800 (Mon, 08 Feb 2010) | 3 lines Emit debug info for unused name space global variable. This will be easily optimized by the optimizer in -O1+ mode. This is done by forcing DECL_LLVM() check earlier, which in turn creates llvm symbol for the decl. It was causing issues with self hosting in non-optimized mode. Modified: llvm-gcc-4.2/trunk/gcc/varasm.c Modified: llvm-gcc-4.2/trunk/gcc/varasm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/varasm.c?rev=96467&r1=96466&r2=96467&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/varasm.c (original) +++ llvm-gcc-4.2/trunk/gcc/varasm.c Wed Feb 17 01:44:58 2010 @@ -1361,15 +1361,7 @@ { const char **type = &first_global_object_name; - /* LLVM LOCAL begin */ - if ( -#ifndef ENABLE_LLVM - !MEM_P (DECL_RTL (decl)) -#else - (DECL_LLVM (decl), 0) -#endif - || first_global_object_name - /* LLVM LOCAL end */ + if (first_global_object_name || !TREE_PUBLIC (decl) || DECL_EXTERNAL (decl) || !DECL_NAME (decl) @@ -1377,7 +1369,15 @@ && (TREE_CODE (decl) != VAR_DECL || (DECL_COMMON (decl) && (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node))))) + || DECL_INITIAL (decl) == error_mark_node)))) + /* LLVM LOCAL begin */ +#ifndef ENABLE_LLVM + || !MEM_P (DECL_RTL (decl)) +#else + || (DECL_LLVM (decl), 0) +#endif + ) + /* LLVM LOCAL end */ return; /* We win when global object is found, but it is useful to know about weak From echristo at apple.com Wed Feb 17 02:53:27 2010 From: echristo at apple.com (Eric Christopher) Date: Wed, 17 Feb 2010 08:53:27 -0000 Subject: [llvm-commits] [llvm] r96474 - in /llvm/trunk/test: FrontendC++/2010-02-08-NamespaceVar.cpp FrontendC/2003-12-14-ExternInlineSupport.c Message-ID: <201002170853.o1H8rRHt017814@zion.cs.uiuc.edu> Author: echristo Date: Wed Feb 17 02:53:27 2010 New Revision: 96474 URL: http://llvm.org/viewvc/llvm-project?rev=96474&view=rev Log: Revert: r95605 | dpatel | 2010-02-08 15:27:46 -0800 (Mon, 08 Feb 2010) | 2 lines test case for r95604. Which was the testcase for the patch reverted from llvm-gcc. Removed: llvm/trunk/test/FrontendC++/2010-02-08-NamespaceVar.cpp Modified: llvm/trunk/test/FrontendC/2003-12-14-ExternInlineSupport.c Removed: llvm/trunk/test/FrontendC++/2010-02-08-NamespaceVar.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2010-02-08-NamespaceVar.cpp?rev=96473&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/2010-02-08-NamespaceVar.cpp (original) +++ llvm/trunk/test/FrontendC++/2010-02-08-NamespaceVar.cpp (removed) @@ -1,16 +0,0 @@ -// RUN: %llvmgxx -S %s -o - | grep cX - -namespace C { - int c = 1; - namespace { - int cX = 6; - void marker2() { - cX; - } - } -} - -int main() { - C::marker2(); - return 0; -} Modified: llvm/trunk/test/FrontendC/2003-12-14-ExternInlineSupport.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2003-12-14-ExternInlineSupport.c?rev=96474&r1=96473&r2=96474&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2003-12-14-ExternInlineSupport.c (original) +++ llvm/trunk/test/FrontendC/2003-12-14-ExternInlineSupport.c Wed Feb 17 02:53:27 2010 @@ -1,3 +1,3 @@ -// RUN: %llvmgcc -Os -xc %s -c -o - | llvm-dis | not grep dead_function +// RUN: %llvmgcc -xc %s -c -o - | llvm-dis | not grep dead_function extern __inline__ void dead_function() {} From baldrick at free.fr Wed Feb 17 04:36:49 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 17 Feb 2010 10:36:49 -0000 Subject: [llvm-commits] [dragonegg] r96475 - /dragonegg/trunk/ Message-ID: <201002171036.o1HAanRF029168@zion.cs.uiuc.edu> Author: baldrick Date: Wed Feb 17 04:36:48 2010 New Revision: 96475 URL: http://llvm.org/viewvc/llvm-project?rev=96475&view=rev Log: Also ignore the generated 'target' program, used to translate between GCC and LLVM target names. Modified: dragonegg/trunk/ (props changed) Propchange: dragonegg/trunk/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Feb 17 04:36:48 2010 @@ -1 +1,2 @@ *.d +target From baldrick at free.fr Wed Feb 17 06:22:10 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 17 Feb 2010 12:22:10 -0000 Subject: [llvm-commits] [dragonegg] r96476 - /dragonegg/trunk/TODO Message-ID: <201002171222.o1HCMAvk001004@zion.cs.uiuc.edu> Author: baldrick Date: Wed Feb 17 06:22:10 2010 New Revision: 96476 URL: http://llvm.org/viewvc/llvm-project?rev=96476&view=rev Log: Add a TODO about better warnings. Modified: dragonegg/trunk/TODO Modified: dragonegg/trunk/TODO URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/TODO?rev=96476&r1=96475&r2=96476&view=diff ============================================================================== --- dragonegg/trunk/TODO (original) +++ dragonegg/trunk/TODO Wed Feb 17 06:22:10 2010 @@ -61,3 +61,7 @@ Many x86 specific builtins are not supported, even though it would be easy to add support for some of them, for example the 256 bit versions of builtins we do support. Improve this. + +The GCC builtin lowering outputs helpful warnings (for example, +20081109_0.c:3:35: warning: attempt to free a non-heap object ???bar???, +see maybe_emit_free_warning), but we don't. Improve this somehow. From baldrick at free.fr Wed Feb 17 08:52:23 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 17 Feb 2010 14:52:23 -0000 Subject: [llvm-commits] [llvm] r96477 - /llvm/trunk/lib/MC/MCAssembler.cpp Message-ID: <201002171452.o1HEqOed008283@zion.cs.uiuc.edu> Author: baldrick Date: Wed Feb 17 08:52:22 2010 New Revision: 96477 URL: http://llvm.org/viewvc/llvm-project?rev=96477&view=rev Log: Pacify gcc-4.5, which warns (correctly) that these switches have cases that are not part of the enum. Modified: llvm/trunk/lib/MC/MCAssembler.cpp Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=96477&r1=96476&r2=96477&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Wed Feb 17 08:52:22 2010 @@ -51,7 +51,7 @@ return (Type == MCSectionMachO::S_ZEROFILL); } -static unsigned getFixupKindLog2Size(MCFixupKind Kind) { +static unsigned getFixupKindLog2Size(unsigned Kind) { switch (Kind) { default: llvm_unreachable("invalid fixup kind!"); case X86::reloc_pcrel_1byte: @@ -64,7 +64,7 @@ } } -static bool isFixupKindPCRel(MCFixupKind Kind) { +static bool isFixupKindPCRel(unsigned Kind) { switch (Kind) { default: return false; From gohman at apple.com Wed Feb 17 11:00:39 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 09:00:39 -0800 Subject: [llvm-commits] [llvm] r96421 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp In-Reply-To: <9847F0C4-FDC3-4645-9B32-E8FEEFE17909@apple.com> References: <201002170037.o1H0bLIP019599@zion.cs.uiuc.edu> <9847F0C4-FDC3-4645-9B32-E8FEEFE17909@apple.com> Message-ID: On Feb 16, 2010, at 4:50 PM, Chris Lattner wrote: > > On Feb 16, 2010, at 4:37 PM, Dan Gohman wrote: > >> Author: djg >> Date: Tue Feb 16 18:37:20 2010 >> New Revision: 96421 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=96421&view=rev >> Log: >> Make the operand and format specifier match, and print all >> 64 bits, fixing a variety of problems. > > Nice catch, does a similar bug exist in the X86IntelInstPrinter? no From gohman at apple.com Wed Feb 17 11:06:22 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 09:06:22 -0800 Subject: [llvm-commits] [llvm] r96214 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h In-Reply-To: <32D5BA33-7A4F-4151-9400-179C94B5A943@apple.com> References: <201002150711.o1F7BZiY028560@zion.cs.uiuc.edu> <176E4A09-7C1B-4831-8926-C11DFB56B69A@apple.com> <32D5BA33-7A4F-4151-9400-179C94B5A943@apple.com> Message-ID: <7BD0B014-271E-44A6-A0C1-21166C63D327@apple.com> On Feb 15, 2010, at 11:13 AM, Chris Lattner wrote: > > On Feb 15, 2010, at 9:21 AM, Dan Gohman wrote: > >> >> On Feb 14, 2010, at 11:11 PM, Chris Lattner wrote: >> >>> Author: lattner >>> Date: Mon Feb 15 01:11:34 2010 >>> New Revision: 96214 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=96214&view=rev >>> Log: >>> give SDValue an operator->, allowing V->isTargetOpcode() and >>> many other natural things. >> >> >> I had been gradually moving everything away from using SDValues >> as if they were SDNodes. While it's convenient to ignore the >> distinction sometimes, it's really hard to follow when it does >> matter. > > I'm ok with it if that is the direction you want to go, but it seems much more natural to treat SDValue as a "rich pointer". It seems much more natural to use V->getOpcode() than V.getOpcode() or V.getOperand() etc. The duplicated methods don't make a lot of sense to me (and yes, I'm to blame for the original poor design). Basically, I think "rich pointer" is the wrong concept for SDValue. It's really a (Node, ResNo) pair, and thinking about it as a pointer means it's carrying around extra bits which sometimes matter and sometimes don't. I'd eventually like to get rid of both V.getOpcode() and V->getOpcode() and replace them with V.getNode()->getOpcode(), for code that really needs to do that kind of thing. Dan From baldrick at free.fr Wed Feb 17 11:20:19 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 17 Feb 2010 17:20:19 -0000 Subject: [llvm-commits] [llvm] r96480 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <201002171720.o1HHKK95015454@zion.cs.uiuc.edu> Author: baldrick Date: Wed Feb 17 11:20:17 2010 New Revision: 96480 URL: http://llvm.org/viewvc/llvm-project?rev=96480&view=rev Log: Mention an API change. Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=96480&r1=96479&r2=96480&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Wed Feb 17 11:20:17 2010 @@ -644,6 +644,10 @@
  • The llvm/Support/DataTypes.h header has moved to llvm/System/DataTypes.h.
  • +
  • The isInteger, isIntOrIntVector, isFloatingPoint, +isFPOrFPVector and isFPOrFPVector methods have been renamed +isIntegerTy, isIntOrIntVectorTy, isFloatingPointTy, +isFPOrFPVectorTy and isFPOrFPVectorTy respectively.
From clattner at apple.com Wed Feb 17 11:45:07 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Feb 2010 09:45:07 -0800 Subject: [llvm-commits] [llvm] r96462 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td In-Reply-To: <201002170631.o1H6VnWN003745@zion.cs.uiuc.edu> References: <201002170631.o1H6VnWN003745@zion.cs.uiuc.edu> Message-ID: On Feb 16, 2010, at 10:31 PM, Johnny Chen wrote: > Author: johnny > Date: Wed Feb 17 00:31:48 2010 > New Revision: 96462 > > URL: http://llvm.org/viewvc/llvm-project?rev=96462&view=rev > Log: > Added BFI for disassembly only. > > A8.6.18 BFI - Bitfield insert (Encoding A1) I'm not sure what this does, but it sounds potentially useful to add a pattern for it. -Chris > > Modified: > llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96462&r1=96461&r2=96462&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Feb 17 00:31:48 2010 > @@ -1443,6 +1443,17 @@ > let Inst{6-0} = 0b0011111; > } > > +// A8.6.18 BFI - Bitfield insert (Encoding A1) > +// Added for disassembler with the pattern field purposely left blank. > +def BFI : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), > + AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, > + "bfi", "\t$dst, $src, $imm", "", > + [/* For disassembly only; pattern left blank */]>, > + Requires<[IsARM, HasV6T2]> { > + let Inst{27-21} = 0b0111110; > + let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15 > +} > + > def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, > "mvn", "\t$dst, $src", > [(set GPR:$dst, (not GPR:$src))]>, UnaryDP { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sanjiv.gupta at microchip.com Wed Feb 17 12:11:29 2010 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Wed, 17 Feb 2010 18:11:29 -0000 Subject: [llvm-commits] [llvm] r96485 - in /llvm/trunk/lib/Target/PIC16/PIC16Passes: PIC16Cloner.cpp PIC16Cloner.h Message-ID: <201002171811.o1HIBTVD018365@zion.cs.uiuc.edu> Author: sgupta Date: Wed Feb 17 12:11:29 2010 New Revision: 96485 URL: http://llvm.org/viewvc/llvm-project?rev=96485&view=rev Log: Added routine to clone the body of a function and maintain a map of already cloned functions. Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp?rev=96485&r1=96484&r2=96485&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp Wed Feb 17 12:11:29 2010 @@ -212,3 +212,41 @@ } // end of loop of all called functions. } +// Clone the given function and return it. +// Note: it uses the ValueMap member of the class, which is already populated +// by cloneAutos by the time we reach here. +// FIXME: Should we just pass ValueMap's ref as a parameter here? rather +// than keeping the ValueMap as a member. +Function * +PIC16Cloner::cloneFunction(Function *OrgF) { + Function *ClonedF; + + // See if we already cloned it. Return that. + cloned_map_iterator cm_it = ClonedFunctionMap.find(OrgF); + if(cm_it != ClonedFunctionMap.end()) { + ClonedF = cm_it->second; + return ClonedF; + } + + // Clone does not exist. + // First clone the autos, and populate ValueMap. + CloneAutos(OrgF); + + // Now create the clone. + ClonedF = CloneFunction(OrgF, ValueMap); + + // The new function should be for interrupt line. Therefore should have + // the name suffixed with IL and section attribute marked with IL. + ClonedF->setName(PAN::getCloneFnName(OrgF->getName())); + ClonedF->setSection("IL"); + + // Add the newly created function to the module. + OrgF->getParent()->getFunctionList().push_back(ClonedF); + + // Update the ClonedFunctionMap to record this cloning activity. + ClonedFunctionMap[OrgF] = ClonedF; + + return ClonedF; +} + + Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h?rev=96485&r1=96484&r2=96485&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h Wed Feb 17 12:11:29 2010 @@ -48,6 +48,9 @@ // Clone auto variables of function specified. void CloneAutos(Function *F); + + // Clone the body of a function. + Function *cloneFunction(Function *F); // Error reporting for PIC16Pass void reportError(string ErrorString, vector &Values); @@ -64,6 +67,10 @@ // This value map is passed during the function cloning so that all the // uses of auto variables be updated properly. DenseMap ValueMap; + + // Map of a already cloned functions. + map ClonedFunctionMap; + typedef map::iterator cloned_map_iterator; }; } // End of anonymous namespace From sabre at nondot.org Wed Feb 17 12:33:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 18:33:13 -0000 Subject: [llvm-commits] [llvm] r96488 - /llvm/trunk/docs/GettingStarted.html Message-ID: <201002171833.o1HIXDmx019616@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 12:33:13 2010 New Revision: 96488 URL: http://llvm.org/viewvc/llvm-project?rev=96488&view=rev Log: add optional debian instructions, PR6272 Modified: llvm/trunk/docs/GettingStarted.html Modified: llvm/trunk/docs/GettingStarted.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=96488&r1=96487&r2=96488&view=diff ============================================================================== --- llvm/trunk/docs/GettingStarted.html (original) +++ llvm/trunk/docs/GettingStarted.html Wed Feb 17 12:33:13 2010 @@ -1193,10 +1193,16 @@

-This allows you to execute LLVM bitcode files directly. Thanks to Jack -Cummings for pointing this out! +This allows you to execute LLVM bitcode files directly. On Debian, you +can also use this command instead of the 'echo' command above:

+
+
+$ sudo update-binfmts --install llvm /path/to/lli --magic 'BC'
+
+
+ From evan.cheng at apple.com Wed Feb 17 12:33:21 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 17 Feb 2010 10:33:21 -0800 Subject: [llvm-commits] [llvm] r96462 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td In-Reply-To: References: <201002170631.o1H6VnWN003745@zion.cs.uiuc.edu> Message-ID: PR5100 On Feb 17, 2010, at 9:45 AM, Chris Lattner wrote: > > On Feb 16, 2010, at 10:31 PM, Johnny Chen wrote: > >> Author: johnny >> Date: Wed Feb 17 00:31:48 2010 >> New Revision: 96462 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=96462&view=rev >> Log: >> Added BFI for disassembly only. >> >> A8.6.18 BFI - Bitfield insert (Encoding A1) > > I'm not sure what this does, but it sounds potentially useful to add a pattern for it. > > -Chris > >> >> Modified: >> llvm/trunk/lib/Target/ARM/ARMInstrInfo.td >> >> Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96462&r1=96461&r2=96462&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) >> +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Feb 17 00:31:48 2010 >> @@ -1443,6 +1443,17 @@ >> let Inst{6-0} = 0b0011111; >> } >> >> +// A8.6.18 BFI - Bitfield insert (Encoding A1) >> +// Added for disassembler with the pattern field purposely left blank. >> +def BFI : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), >> + AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, >> + "bfi", "\t$dst, $src, $imm", "", >> + [/* For disassembly only; pattern left blank */]>, >> + Requires<[IsARM, HasV6T2]> { >> + let Inst{27-21} = 0b0111110; >> + let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15 >> +} >> + >> def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, >> "mvn", "\t$dst, $src", >> [(set GPR:$dst, (not GPR:$src))]>, UnaryDP { >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Wed Feb 17 12:39:57 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 18:39:57 -0000 Subject: [llvm-commits] [llvm] r96489 - /llvm/trunk/include/llvm/Support/TargetFolder.h Message-ID: <201002171839.o1HIdvfx020038@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 12:39:56 2010 New Revision: 96489 URL: http://llvm.org/viewvc/llvm-project?rev=96489&view=rev Log: add missing method, PR6284 Modified: llvm/trunk/include/llvm/Support/TargetFolder.h Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=96489&r1=96488&r2=96489&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Wed Feb 17 12:39:56 2010 @@ -185,7 +185,9 @@ return C; // avoid calling Fold return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned)); } - + Constant *CreatePointerCast(Constant *C, const Type *DestTy) const { + return ConstantExpr::getPointerCast(C, DestTy); + } Constant *CreateBitCast(Constant *C, const Type *DestTy) const { return CreateCast(Instruction::BitCast, C, DestTy); } From sabre at nondot.org Wed Feb 17 12:42:24 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 18:42:24 -0000 Subject: [llvm-commits] [llvm] r96490 - /llvm/trunk/lib/Target/ARM/README.txt Message-ID: <201002171842.o1HIgOBe020255@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 12:42:24 2010 New Revision: 96490 URL: http://llvm.org/viewvc/llvm-project?rev=96490&view=rev Log: add a note, from PR5100 Modified: llvm/trunk/lib/Target/ARM/README.txt Modified: llvm/trunk/lib/Target/ARM/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=96490&r1=96489&r2=96490&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/README.txt (original) +++ llvm/trunk/lib/Target/ARM/README.txt Wed Feb 17 12:42:24 2010 @@ -10,6 +10,8 @@ * Implement pre/post increment support. (e.g. PR935) * Implement smarter constant generation for binops with large immediates. +A few ARMv6T2 ops should be pattern matched: BFI, SBFX, and UBFX + //===---------------------------------------------------------------------===// Crazy idea: Consider code that uses lots of 8-bit or 16-bit values. By the From cdavis at mymail.mines.edu Wed Feb 17 12:45:30 2010 From: cdavis at mymail.mines.edu (Charles Davis) Date: Wed, 17 Feb 2010 11:45:30 -0700 Subject: [llvm-commits] [PATCH] Support the 'alignstack' attribute in the x86 backend Message-ID: <4B7C394A.3010902@mymail.mines.edu> This patch in the force_align_arg_pointer series adds support for the alignstack() attribute to the x86 backend. It's a very simple patch, but I feel like it's missing something. Comments are welcome. A test case is included. I hope I put it in the right place. I also took the liberty of FileCheck'izing it. Chip -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: faap-support-4.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100217/dcbe6ba2/attachment.pl From sabre at nondot.org Wed Feb 17 12:52:57 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 18:52:57 -0000 Subject: [llvm-commits] [llvm] r96492 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/CodeGen/MachineBasicBlock.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/MachineBasicBlock.cpp lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002171852.o1HIqvI0020980@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 12:52:56 2010 New Revision: 96492 URL: http://llvm.org/viewvc/llvm-project?rev=96492&view=rev Log: move isOnlyReachableByFallthrough out of MachineBasicBlock into AsmPrinter, and add a sparc implementation that knows about delay slots. Patch by Nathan Keynes! Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=96492&r1=96491&r2=96492&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Feb 17 12:52:56 2010 @@ -356,6 +356,11 @@ /// printOffset - This is just convenient handler for printing offsets. void printOffset(int64_t Offset) const; + /// isBlockOnlyReachableByFallthough - Return true if the basic block has + /// exactly one predecessor and the control transfer mechanism between + /// the predecessor and this block is a fall-through. + virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const; + private: /// processDebugLoc - Processes the debug information of each machine Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=96492&r1=96491&r2=96492&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Wed Feb 17 12:52:56 2010 @@ -285,11 +285,6 @@ /// it returns end() iterator getFirstTerminator(); - /// isOnlyReachableViaFallthough - Return true if this basic block has - /// exactly one predecessor and the control transfer mechanism between - /// the predecessor and this block is a fall-through. - bool isOnlyReachableByFallthrough() const; - void pop_front() { Insts.pop_front(); } void pop_back() { Insts.pop_back(); } void push_back(MachineInstr *MI) { Insts.push_back(MI); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=96492&r1=96491&r2=96492&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Feb 17 12:52:56 2010 @@ -1717,7 +1717,7 @@ } // Print the main label for the block. - if (MBB->pred_empty() || MBB->isOnlyReachableByFallthrough()) { + if (MBB->pred_empty() || isBlockOnlyReachableByFallthrough(MBB)) { if (VerboseAsm) { // NOTE: Want this comment at start of line. O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':'; @@ -1764,6 +1764,39 @@ O << Offset; } +/// isBlockOnlyReachableByFallthough - Return true if the basic block has +/// exactly one predecessor and the control transfer mechanism between +/// the predecessor and this block is a fall-through. +bool AsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) + const { + // If this is a landing pad, it isn't a fall through. If it has no preds, + // then nothing falls through to it. + if (MBB->isLandingPad() || MBB->pred_empty()) + return false; + + // If there isn't exactly one predecessor, it can't be a fall through. + MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), PI2 = PI; + ++PI2; + if (PI2 != MBB->pred_end()) + return false; + + // The predecessor has to be immediately before this block. + const MachineBasicBlock *Pred = *PI; + + if (!Pred->isLayoutSuccessor(MBB)) + return false; + + // If the block is completely empty, then it definitely does fall through. + if (Pred->empty()) + return true; + + // Otherwise, check the last instruction. + const MachineInstr &LastInst = Pred->back(); + return !LastInst.getDesc().isBarrier(); +} + + + GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) { if (!S->usesMetadata()) return 0; Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=96492&r1=96491&r2=96492&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Feb 17 12:52:56 2010 @@ -143,36 +143,6 @@ return I; } -/// isOnlyReachableViaFallthough - Return true if this basic block has -/// exactly one predecessor and the control transfer mechanism between -/// the predecessor and this block is a fall-through. -bool MachineBasicBlock::isOnlyReachableByFallthrough() const { - // If this is a landing pad, it isn't a fall through. If it has no preds, - // then nothing falls through to it. - if (isLandingPad() || pred_empty()) - return false; - - // If there isn't exactly one predecessor, it can't be a fall through. - const_pred_iterator PI = pred_begin(), PI2 = PI; - ++PI2; - if (PI2 != pred_end()) - return false; - - // The predecessor has to be immediately before this block. - const MachineBasicBlock *Pred = *PI; - - if (!Pred->isLayoutSuccessor(this)) - return false; - - // If the block is completely empty, then it definitely does fall through. - if (Pred->empty()) - return true; - - // Otherwise, check the last instruction. - const MachineInstr &LastInst = Pred->back(); - return !LastInst.getDesc().isBarrier(); -} - void MachineBasicBlock::dump() const { print(dbgs()); } Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=96492&r1=96491&r2=96492&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Wed Feb 17 12:52:56 2010 @@ -56,6 +56,9 @@ unsigned AsmVariant, const char *ExtraCode); bool printGetPCX(const MachineInstr *MI, unsigned OpNo); + + virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) + const; }; } // end of anonymous namespace @@ -197,6 +200,38 @@ return false; } +/// isBlockOnlyReachableByFallthough - Return true if the basic block has +/// exactly one predecessor and the control transfer mechanism between +/// the predecessor and this block is a fall-through. +/// Override AsmPrinter implementation to handle delay slots +bool SparcAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) + const { + // If this is a landing pad, it isn't a fall through. If it has no preds, + // then nothing falls through to it. + if (MBB->isLandingPad() || MBB->pred_empty()) + return false; + + // If there isn't exactly one predecessor, it can't be a fall through. + MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), PI2 = PI; + ++PI2; + if (PI2 != MBB->pred_end()) + return false; + + // The predecessor has to be immediately before this block. + const MachineBasicBlock *Pred = *PI; + + if (!Pred->isLayoutSuccessor(MBB)) + return false; + + // Check if the last terminator is an unconditional branch + MachineBasicBlock::const_iterator I = Pred->end(); + while( I != Pred->begin() && !(--I)->getDesc().isTerminator() ) + ; /* Noop */ + return I == Pred->end() || !I->getDesc().isBarrier(); +} + + + // Force static initialization. extern "C" void LLVMInitializeSparcAsmPrinter() { RegisterAsmPrinter X(TheSparcTarget); Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96492&r1=96491&r2=96492&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Feb 17 12:52:56 2010 @@ -1975,7 +1975,7 @@ // definitions. Emit the resultant instruction selector. EmitInstructionSelector(OS); -#if 0 +#if 1 MatcherNode *Matcher = 0; // Walk the patterns backwards, building a matcher for each and adding it to // the matcher for the whole target. From sabre at nondot.org Wed Feb 17 12:57:20 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 18:57:20 -0000 Subject: [llvm-commits] [llvm] r96495 - /llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Message-ID: <201002171857.o1HIvLFJ021311@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 12:57:19 2010 New Revision: 96495 URL: http://llvm.org/viewvc/llvm-project?rev=96495&view=rev Log: "Fix and issue in SparcAsmPrinter where multiple identical .LLGETPCHn symbols could be emitted in the same file (it was uniqued by block number, but not by function number). " Patch by Nathan Keynes! Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=96495&r1=96494&r2=96495&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Wed Feb 17 12:57:19 2010 @@ -143,18 +143,19 @@ break; } + unsigned mfNum = MI->getParent()->getParent()->getFunctionNumber(); unsigned bbNum = MI->getParent()->getNumber(); - O << '\n' << ".LLGETPCH" << bbNum << ":\n"; - O << "\tcall\t.LLGETPC" << bbNum << '\n' ; + O << '\n' << ".LLGETPCH" << mfNum << '_' << bbNum << ":\n"; + O << "\tcall\t.LLGETPC" << mfNum << '_' << bbNum << '\n' ; O << "\t sethi\t" - << "%hi(_GLOBAL_OFFSET_TABLE_+(.-.LLGETPCH" << bbNum << ")), " + << "%hi(_GLOBAL_OFFSET_TABLE_+(.-.LLGETPCH" << mfNum << '_' << bbNum << ")), " << operand << '\n' ; - O << ".LLGETPC" << bbNum << ":\n" ; + O << ".LLGETPC" << mfNum << '_' << bbNum << ":\n" ; O << "\tor\t" << operand - << ", %lo(_GLOBAL_OFFSET_TABLE_+(.-.LLGETPCH" << bbNum << ")), " + << ", %lo(_GLOBAL_OFFSET_TABLE_+(.-.LLGETPCH" << mfNum << '_' << bbNum << ")), " << operand << '\n'; O << "\tadd\t" << operand << ", %o7, " << operand << '\n'; From gohman at apple.com Wed Feb 17 13:12:08 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 11:12:08 -0800 Subject: [llvm-commits] [llvm] r96492 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/CodeGen/MachineBasicBlock.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/MachineBasicBlock.cpp lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp utils/TableGen/DAGISelEmitter.cpp In-Reply-To: <201002171852.o1HIqvI0020980@zion.cs.uiuc.edu> References: <201002171852.o1HIqvI0020980@zion.cs.uiuc.edu> Message-ID: <7E58DCA8-044C-442B-B13C-F062685724C3@apple.com> On Feb 17, 2010, at 10:52 AM, Chris Lattner wrote: > +/// isBlockOnlyReachableByFallthough - Return true if the basic block has > +/// exactly one predecessor and the control transfer mechanism between > +/// the predecessor and this block is a fall-through. > +/// Override AsmPrinter implementation to handle delay slots > +bool SparcAsmPrinter::isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) > + const { > + // If this is a landing pad, it isn't a fall through. If it has no preds, > + // then nothing falls through to it. > + if (MBB->isLandingPad() || MBB->pred_empty()) > + return false; > + > + // If there isn't exactly one predecessor, it can't be a fall through. > + MachineBasicBlock::const_pred_iterator PI = MBB->pred_begin(), PI2 = PI; > + ++PI2; > + if (PI2 != MBB->pred_end()) > + return false; > + > + // The predecessor has to be immediately before this block. > + const MachineBasicBlock *Pred = *PI; > + > + if (!Pred->isLayoutSuccessor(MBB)) > + return false; > + > + // Check if the last terminator is an unconditional branch > + MachineBasicBlock::const_iterator I = Pred->end(); > + while( I != Pred->begin() && !(--I)->getDesc().isTerminator() ) > + ; /* Noop */ > + return I == Pred->end() || !I->getDesc().isBarrier(); Please follow LLVM whitespace conventions. This code is non-obvious. The rest of CodeGen does not support terminator instructions that aren't at the end of the block. Please add a comment mentioning that this is for delay slots. > +} > + > + > + > // Force static initialization. > extern "C" void LLVMInitializeSparcAsmPrinter() { > RegisterAsmPrinter X(TheSparcTarget); > > Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96492&r1=96491&r2=96492&view=diff > > ============================================================================== > --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Feb 17 12:52:56 2010 > @@ -1975,7 +1975,7 @@ > // definitions. Emit the resultant instruction selector. > EmitInstructionSelector(OS); > > -#if 0 > +#if 1 This probably wasn't intended. Dan From stoklund at 2pi.dk Wed Feb 17 13:13:57 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 17 Feb 2010 19:13:57 -0000 Subject: [llvm-commits] [llvm] r96496 - in /llvm/trunk/lib/CodeGen: PHIElimination.cpp PHIElimination.h Message-ID: <201002171913.o1HJDvh2022211@zion.cs.uiuc.edu> Author: stoklund Date: Wed Feb 17 13:13:56 2010 New Revision: 96496 URL: http://llvm.org/viewvc/llvm-project?rev=96496&view=rev Log: Dead code elimination. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp llvm/trunk/lib/CodeGen/PHIElimination.h Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=96496&r1=96495&r2=96496&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Wed Feb 17 13:13:56 2010 @@ -56,7 +56,6 @@ MRI = &Fn.getRegInfo(); PHIDefs.clear(); - PHIKills.clear(); bool Changed = false; // Split critical edges to help the coalescer @@ -276,9 +275,6 @@ // path the PHI. MachineBasicBlock &opBlock = *MPhi->getOperand(i*2+2).getMBB(); - // Record the kill. - PHIKills[SrcReg].insert(&opBlock); - // If source is defined by an implicit def, there is no need to insert a // copy. MachineInstr *DefMI = MRI->getVRegDef(SrcReg); Modified: llvm/trunk/lib/CodeGen/PHIElimination.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=96496&r1=96495&r2=96496&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.h (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.h Wed Feb 17 13:13:56 2010 @@ -22,17 +22,10 @@ /// Lower PHI instructions to copies. class PHIElimination : public MachineFunctionPass { MachineRegisterInfo *MRI; // Machine register information - private: - - typedef SmallSet PHIKillList; - typedef DenseMap PHIKillMap; typedef DenseMap PHIDefMap; public: - typedef PHIKillList::iterator phi_kill_iterator; - typedef PHIKillList::const_iterator const_phi_kill_iterator; - static char ID; // Pass identification, replacement for typeid PHIElimination() : MachineFunctionPass(&ID) {} @@ -46,32 +39,6 @@ return PHIDefs.count(vreg); } - /// Returns the block in which the PHI instruction which defined the - /// given vreg used to reside. - MachineBasicBlock* getPHIDefBlock(unsigned vreg) { - PHIDefMap::iterator phiDefItr = PHIDefs.find(vreg); - assert(phiDefItr != PHIDefs.end() && "vreg has no phi-def."); - return phiDefItr->second; - } - - /// Returns true if the given vreg was killed by a PHI instr. - bool hasPHIKills(unsigned vreg) const { - return PHIKills.count(vreg); - } - - /// Returns an iterator over the BasicBlocks which contained PHI - /// kills of this register prior to lowering. - phi_kill_iterator phiKillsBegin(unsigned vreg) { - PHIKillMap::iterator phiKillItr = PHIKills.find(vreg); - assert(phiKillItr != PHIKills.end() && "vreg has no phi-kills."); - return phiKillItr->second.begin(); - } - phi_kill_iterator phiKillsEnd(unsigned vreg) { - PHIKillMap::iterator phiKillItr = PHIKills.find(vreg); - assert(phiKillItr != PHIKills.end() && "vreg has no phi-kills."); - return phiKillItr->second.end(); - } - private: /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions /// in predecessor basic blocks. @@ -140,7 +107,6 @@ VRegPHIUse VRegPHIUseCount; PHIDefMap PHIDefs; - PHIKillMap PHIKills; // Defs of PHI sources which are implicit_def. SmallPtrSet ImpDefs; From sabre at nondot.org Wed Feb 17 13:19:51 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 19:19:51 -0000 Subject: [llvm-commits] [llvm] r96497 - /llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002171919.o1HJJpus022483@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 13:19:50 2010 New Revision: 96497 URL: http://llvm.org/viewvc/llvm-project?rev=96497&view=rev Log: redisable this to save people a small amount of build time. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96497&r1=96496&r2=96497&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Feb 17 13:19:50 2010 @@ -1975,7 +1975,7 @@ // definitions. Emit the resultant instruction selector. EmitInstructionSelector(OS); -#if 1 +#if 0 MatcherNode *Matcher = 0; // Walk the patterns backwards, building a matcher for each and adding it to // the matcher for the whole target. From anton at korobeynikov.info Wed Feb 17 13:20:06 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 17 Feb 2010 22:20:06 +0300 Subject: [llvm-commits] [PATCH] Support the 'alignstack' attribute in the x86 backend In-Reply-To: <4B7C394A.3010902@mymail.mines.edu> References: <4B7C394A.3010902@mymail.mines.edu> Message-ID: Hello, Charles > This patch in the force_align_arg_pointer series adds support for the > alignstack() attribute to the x86 backend. It's a very simple patch, but > I feel like it's missing something. Yes, a bit. Two questions: 1. What if current stack alignment is more than specified by attribute. In such case no realignment will be needed. However, I feel that in such case your patch will force realignment as well. Try to increase the stack alignment and / or just try the stuff with darwin. 2. Are you sure that the maximum alignment you set won't be clobberred in the case when e.g. there will be vector spills? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From daniel at zuster.org Wed Feb 17 13:26:46 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 17 Feb 2010 19:26:46 -0000 Subject: [llvm-commits] [llvm] r96498 - /llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h Message-ID: <201002171926.o1HJQkTl022784@zion.cs.uiuc.edu> Author: ddunbar Date: Wed Feb 17 13:26:45 2010 New Revision: 96498 URL: http://llvm.org/viewvc/llvm-project?rev=96498&view=rev Log: Fix comment. Modified: llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h Modified: llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h?rev=96498&r1=96497&r2=96498&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h (original) +++ llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h Wed Feb 17 13:26:45 2010 @@ -52,7 +52,7 @@ /// \return - The test result. bool GetTestResult(const changeset_ty &Changes); - /// Split - Partition a set of changes \arg Sinto one or two subsets. + /// Split - Partition a set of changes \arg S into one or two subsets. void Split(const changeset_ty &S, changesetlist_ty &Res); /// Delta - Minimize a set of \arg Changes which has been partioned into From clattner at apple.com Wed Feb 17 13:29:30 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Feb 2010 11:29:30 -0800 Subject: [llvm-commits] [llvm] r96214 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h In-Reply-To: <7BD0B014-271E-44A6-A0C1-21166C63D327@apple.com> References: <201002150711.o1F7BZiY028560@zion.cs.uiuc.edu> <176E4A09-7C1B-4831-8926-C11DFB56B69A@apple.com> <32D5BA33-7A4F-4151-9400-179C94B5A943@apple.com> <7BD0B014-271E-44A6-A0C1-21166C63D327@apple.com> Message-ID: <0EF05925-90C2-4980-9EDD-0FCDD60EE4A3@apple.com> On Feb 17, 2010, at 9:06 AM, Dan Gohman wrote: >> >> I'm ok with it if that is the direction you want to go, but it seems much more natural to treat SDValue as a "rich pointer". It seems much more natural to use V->getOpcode() than V.getOpcode() or V.getOperand() etc. The duplicated methods don't make a lot of sense to me (and yes, I'm to blame for the original poor design). > > Basically, I think "rich pointer" is the wrong concept for SDValue. > It's really a (Node, ResNo) pair, and thinking about it as a pointer > means it's carrying around extra bits which sometimes matter and > sometimes don't. I understand the desire to avoid the extra cost, but if passed by value it should be *that* bad, should it? > I'd eventually like to get rid of both V.getOpcode() and V->getOpcode() > and replace them with V.getNode()->getOpcode(), for code that really > needs to do that kind of thing. I'm ok with that if we really do get rid of the convenience functions. It seems extremely inconvenient and verbose to always have to use .getNode()-> though. -Chris From jyasskin at google.com Wed Feb 17 13:31:12 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Wed, 17 Feb 2010 11:31:12 -0800 Subject: [llvm-commits] [PATCH] Shared library for LLVM (issue198059) In-Reply-To: References: <0016e64640dcdc5da0047ee1e48d@google.com> Message-ID: Ping? On Tue, Feb 9, 2010 at 9:58 AM, Jeffrey Yasskin wrote: > I've fixed the llvm-config problem: > http://codereview.appspot.com/download/issue198059_5012.diff > > On Fri, Feb 5, 2010 at 2:22 PM, ? wrote: >> Reviewers: llvm-commits_cs.uiuc.edu, >> >> Message: >> We've had requests from packagers in the Unladen Swallow merge PEP that >> we link shared against LLVM instead of statically. This patch builds a >> libLLVM2.7svn.(so|dylib) and adds an --enable-shared configure flag to >> have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll >> change to "2.7" in the release.) >> >> On my mac laptop, libLLVM2.7svn.dylib is 39MB, and opt (for example) is >> 15M static vs 440K shared. >> >> I know of two things that are less than ideal here: >> 1) llvm-config gets rebuilt on the second build from an empty objdir. >> It's noticing that libLLVM.dylib got created after it did and might have >> dependencies. I'm looking into how to fix this. >> 2) The library doesn't include any version information. Since we expect >> to break the ABI with every release, I don't expect this to be much of a >> problem. If we do release a compatible 2.7.1, we may be able to hack its >> library to work with binaries compiled against 2.7.0, or we can just ask >> them to recompile. I'm hoping to get a real packaging expert to look at >> this for the 2.8 release. >> >> Current patch at >> http://codereview.appspot.com/download/issue198059_3001.diff. >> >> Description: >> We've had requests from packagers in the Unladen Swallow merge PEP that >> we link shared against an LLVM instead of statically. This patch builds >> a libLLVM2.7svn.(so|dylib) and adds an --enable-shared configure flag to >> have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll >> change to "2.7" in the release.) >> >> On my mac laptop, libLLVM2.7svn.dylib is 39MB, and opt (for example) is >> 15M static vs 440K shared. >> >> I know of two things that are less than ideal here: >> 1) llvm-config gets rebuilt on the second build from an empty objdir. >> It's noticing that libLLVM.dylib got created after it did and might have >> dependencies. I'm looking into how to fix this. >> 2) The library doesn't include any version information. Since we expect >> to break the ABI with every release, I don't expect this to be much of a >> problem. If we do release a compatible 2.7.1, we may be able to hack its >> library to work with binaries compiled against 2.7.0, or we can just ask >> them to recompile. I'm hoping to get a real packaging expert to look at >> this for the 2.8 release. >> >> Fixes http://llvm.org/PR3201. >> >> Please review this at http://codereview.appspot.com/198059/show >> >> Affected files: >> ? M ? ? Makefile >> ? M ? ? Makefile.config.in >> ? M ? ? Makefile.rules >> ? M ? ? autoconf/configure.ac >> ? M ? ? configure >> ? M ? ? test/Makefile >> ? M ? ? test/Unit/lit.cfg >> ? M ? ? test/Unit/lit.site.cfg.in >> ? A ? ? tools/shlib/Makefile >> ? M ? ? unittests/Makefile.unittest >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From echristo at apple.com Wed Feb 17 13:33:10 2010 From: echristo at apple.com (Eric Christopher) Date: Wed, 17 Feb 2010 11:33:10 -0800 Subject: [llvm-commits] [PATCH] Shared library for LLVM (issue198059) In-Reply-To: References: <0016e64640dcdc5da0047ee1e48d@google.com> Message-ID: On Feb 17, 2010, at 11:31 AM, Jeffrey Yasskin wrote: > Ping? Looks reasonable to me. If you can not diff regenerated files next time that would be helpful :) Thanks! -eric From clattner at apple.com Wed Feb 17 13:38:40 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Feb 2010 11:38:40 -0800 Subject: [llvm-commits] [PATCH] Shared library for LLVM (issue198059) In-Reply-To: References: <0016e64640dcdc5da0047ee1e48d@google.com> Message-ID: On Feb 17, 2010, at 11:31 AM, Jeffrey Yasskin wrote: > Ping? This looks fine to me (though I can't review the lit changes), please name it llvm/tools/llvm-shlib though. FWIW, I'd rather get this in sooner rather than later in case any issues pop up. Would it also be possible to get a single test to verify that the library is working? -Chris > > On Tue, Feb 9, 2010 at 9:58 AM, Jeffrey Yasskin wrote: >> I've fixed the llvm-config problem: >> http://codereview.appspot.com/download/issue198059_5012.diff >> >> On Fri, Feb 5, 2010 at 2:22 PM, wrote: >>> Reviewers: llvm-commits_cs.uiuc.edu, >>> >>> Message: >>> We've had requests from packagers in the Unladen Swallow merge PEP that >>> we link shared against LLVM instead of statically. This patch builds a >>> libLLVM2.7svn.(so|dylib) and adds an --enable-shared configure flag to >>> have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll >>> change to "2.7" in the release.) >>> >>> On my mac laptop, libLLVM2.7svn.dylib is 39MB, and opt (for example) is >>> 15M static vs 440K shared. >>> >>> I know of two things that are less than ideal here: >>> 1) llvm-config gets rebuilt on the second build from an empty objdir. >>> It's noticing that libLLVM.dylib got created after it did and might have >>> dependencies. I'm looking into how to fix this. >>> 2) The library doesn't include any version information. Since we expect >>> to break the ABI with every release, I don't expect this to be much of a >>> problem. If we do release a compatible 2.7.1, we may be able to hack its >>> library to work with binaries compiled against 2.7.0, or we can just ask >>> them to recompile. I'm hoping to get a real packaging expert to look at >>> this for the 2.8 release. >>> >>> Current patch at >>> http://codereview.appspot.com/download/issue198059_3001.diff. >>> >>> Description: >>> We've had requests from packagers in the Unladen Swallow merge PEP that >>> we link shared against an LLVM instead of statically. This patch builds >>> a libLLVM2.7svn.(so|dylib) and adds an --enable-shared configure flag to >>> have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll >>> change to "2.7" in the release.) >>> >>> On my mac laptop, libLLVM2.7svn.dylib is 39MB, and opt (for example) is >>> 15M static vs 440K shared. >>> >>> I know of two things that are less than ideal here: >>> 1) llvm-config gets rebuilt on the second build from an empty objdir. >>> It's noticing that libLLVM.dylib got created after it did and might have >>> dependencies. I'm looking into how to fix this. >>> 2) The library doesn't include any version information. Since we expect >>> to break the ABI with every release, I don't expect this to be much of a >>> problem. If we do release a compatible 2.7.1, we may be able to hack its >>> library to work with binaries compiled against 2.7.0, or we can just ask >>> them to recompile. I'm hoping to get a real packaging expert to look at >>> this for the 2.8 release. >>> >>> Fixes http://llvm.org/PR3201. >>> >>> Please review this at http://codereview.appspot.com/198059/show >>> >>> Affected files: >>> M Makefile >>> M Makefile.config.in >>> M Makefile.rules >>> M autoconf/configure.ac >>> M configure >>> M test/Makefile >>> M test/Unit/lit.cfg >>> M test/Unit/lit.site.cfg.in >>> A tools/shlib/Makefile >>> M unittests/Makefile.unittest >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Wed Feb 17 13:51:31 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 19:51:31 -0000 Subject: [llvm-commits] [llvm] r96500 - /llvm/trunk/docs/tutorial/LangImpl3.html Message-ID: <201002171951.o1HJpVkT024286@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 13:51:31 2010 New Revision: 96500 URL: http://llvm.org/viewvc/llvm-project?rev=96500&view=rev Log: fix some out of date prose dating from the LLVMContext changes. Modified: llvm/trunk/docs/tutorial/LangImpl3.html Modified: llvm/trunk/docs/tutorial/LangImpl3.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl3.html?rev=96500&r1=96499&r2=96500&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl3.html (original) +++ llvm/trunk/docs/tutorial/LangImpl3.html Wed Feb 17 13:51:31 2010 @@ -170,7 +170,7 @@ constants of Arbitrary Precision). This code basically just creates and returns a ConstantFP. Note that in the LLVM IR that constants are all uniqued together and shared. For this reason, the API -uses "the Context.get..." idiom instead of "new foo(..)" or "foo::Create(..)".

+uses the "foo::get(...)" idiom instead of "new foo(..)" or "foo::Create(..)".

@@ -323,10 +323,10 @@
 by an expression), it makes sense for it to return the LLVM Function it
 corresponds to when codegen'd.

-

The call to Context.get creates +

The call to FunctionType::get creates the FunctionType that should be used for a given Prototype. Since all function arguments in Kaleidoscope are of type double, the first line creates -a vector of "N" LLVM double types. It then uses the Context.get +a vector of "N" LLVM double types. It then uses the Functiontype::get method to create a function type that takes "N" doubles as arguments, returns one double as a result, and that is not vararg (the false parameter indicates this). Note that Types in LLVM are uniqued just like Constants are, so you From sabre at nondot.org Wed Feb 17 13:54:34 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Feb 2010 19:54:34 -0000 Subject: [llvm-commits] [llvm] r96502 - /llvm/trunk/docs/tutorial/LangImpl3.html Message-ID: <201002171954.o1HJsYXL024467@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 13:54:34 2010 New Revision: 96502 URL: http://llvm.org/viewvc/llvm-project?rev=96502&view=rev Log: irbuilder is doing constant folding now by default, PR6092 Modified: llvm/trunk/docs/tutorial/LangImpl3.html Modified: llvm/trunk/docs/tutorial/LangImpl3.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl3.html?rev=96502&r1=96501&r2=96502&view=diff ============================================================================== --- llvm/trunk/docs/tutorial/LangImpl3.html (original) +++ llvm/trunk/docs/tutorial/LangImpl3.html Wed Feb 17 13:54:34 2010 @@ -535,8 +535,7 @@ Read top-level expression: define double @""() { entry: - %addtmp = add double 4.000000e+00, 5.000000e+00 - ret double %addtmp + ret double 9.000000e+00 }

@@ -544,7 +543,8 @@

Note how the parser turns the top-level expression into anonymous functions for us. This will be handy when we add JIT support in the next chapter. Also note that the code is very literally -transcribed, no optimizations are being performed. We will +transcribed, no optimizations are being performed except simple constant +folding done by IRBuilder. We will add optimizations explicitly in the next chapter.

From cdavis at mymail.mines.edu Wed Feb 17 13:55:29 2010 From: cdavis at mymail.mines.edu (Charles Davis) Date: Wed, 17 Feb 2010 12:55:29 -0700 Subject: [llvm-commits] [PATCH] Support the 'alignstack' attribute in the x86 backend In-Reply-To: References: <4B7C394A.3010902@mymail.mines.edu> Message-ID: <4B7C49B1.8060803@mymail.mines.edu> Anton Korobeynikov wrote: > Hello, Charles > >> This patch in the force_align_arg_pointer series adds support for the >> alignstack() attribute to the x86 backend. It's a very simple patch, but >> I feel like it's missing something. > Yes, a bit. Two questions: > 1. What if current stack alignment is more than specified by > attribute. In such case no realignment will be needed. However, I feel > that in such case your patch will force realignment as well. Try to > increase the stack alignment and / or just try the stuff with darwin. Uhhh... I run Darwin. Also, I think that's the behavior we want. In Wine, they use the force_align_arg_pointer attribute because their functions are called from code that only keeps the stack aligned to 4 bytes. But since the default alignment on Darwin is 16 bytes, if we do it the way you suggest, the force realignment won't take place, making this useless and we'll be right back where we started. The point of this is to FORCE the stack to be aligned to a certain value, even if the ABI says the stack is aligned to some other value. > 2. Are you sure that the maximum alignment you set won't be clobberred > in the case when e.g. there will be vector spills? I am now. Patch reattached with stronger test case. Chip -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: faap-support-4.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100217/24290d85/attachment.pl From gohman at apple.com Wed Feb 17 13:55:37 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 11:55:37 -0800 Subject: [llvm-commits] patch: moving unreachable elimination to codegenprep In-Reply-To: <4B79FC3C.9020001@mxc.ca> References: <4B68588F.7070906@mxc.ca> <4B6907EF.4050003@mxc.ca> <4B79FC3C.9020001@mxc.ca> Message-ID: <0731D70C-F6B3-49CE-B735-CF94122DE11B@apple.com> On Feb 15, 2010, at 6:00 PM, Nick Lewycky wrote: > Dan Gohman wrote: >> >> On 2 February 2010 21:21, Nick Lewycky wrote: >>> >>> Jakob, I'll make the tweaks to InlineCost that you proposed and post an >>> updated patch with the results of a nightly test run. Realize that I'm >>> expecting no visible performance difference at all since no code in the >>> nightly test uses __builtin_unreachable(). >> >> There is code which uses things like "noreturn" and other >> things which can lead to unreachable getting generated. >> Offhand you may be right that these wouldn't be affected >> though. This happens to be a very testable hypothesis :). > > A 'noreturn' function call turns into a call + unreachable. The call can't be eliminated, so this patch has no effect on that case, since it's not a branch to unreachable (it'd a branch to call). Ok. > I want to emphasize that this patch is not nearly as scary as you seem to think it is. :-) Artificially keeping dead instructions live is not customary in LLVM behavior. CodeGenPrepare is *really* late. The relative sparsity of asm diffs is encouraging, so I won't interfere. I do reserve some misgivings though. > >> Would you mind compiling some tests with and without the >> change, and diffing the .s files? I'd be interested in >> learning what kinds of diffs, if any, appear. > > Done, asmchanges.diff attached. Original is - with my patch is + . I took TEST.llc.Makefile and modified it to keep the .s files, then did a run with and without the patch to see what happens to the output. Everything different was diff'd and all the differences that were irrelevant (timestamp, filename, anonymous namespace(!)) were removed. The remaining differences are a complete mystery to me -- I wonder whether two runs of llc even emit the same thing. :) I've looked into some llc determinism problems recently. With the exception of a few problems which are now fixed, llc output is reproducible for things I've looked at. If you know of cases where it isn't, please file bugs. It seems like the very first diff here, yyerror, is a fairly small function which should be easy enough to understand. Does it diverse in opt or llc? If llc, can you run llc with -print-machineinstrs -print-lsr-output -print-isel-input and figure out where it diverges? Thanks, Dan From daniel at zuster.org Wed Feb 17 14:08:43 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 17 Feb 2010 20:08:43 -0000 Subject: [llvm-commits] [llvm] r96503 - in /llvm/trunk: include/llvm/Support/Regex.h lib/Support/Regex.cpp unittests/Support/RegexTest.cpp Message-ID: <201002172008.o1HK8hVK025542@zion.cs.uiuc.edu> Author: ddunbar Date: Wed Feb 17 14:08:42 2010 New Revision: 96503 URL: http://llvm.org/viewvc/llvm-project?rev=96503&view=rev Log: Add Regex::sub, for doing regular expression substitution with backreferences. Modified: llvm/trunk/include/llvm/Support/Regex.h llvm/trunk/lib/Support/Regex.cpp llvm/trunk/unittests/Support/RegexTest.cpp Modified: llvm/trunk/include/llvm/Support/Regex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Regex.h?rev=96503&r1=96502&r2=96503&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Regex.h (original) +++ llvm/trunk/include/llvm/Support/Regex.h Wed Feb 17 14:08:42 2010 @@ -56,6 +56,19 @@ /// /// This returns true on a successful match. bool match(const StringRef &String, SmallVectorImpl *Matches=0); + + /// sub - Return the result of replacing the first match of the regex in + /// \arg String with the \arg Repl string. Backreferences like "\0" in the + /// replacement string are replaced with the appropriate match substring. + /// + /// Note that the replacement string has backslash escaping performed on + /// it. Invalid backreferences are ignored (replaced by empty strings). + /// + /// \param Error If non-null, any errors in the substitution (invalid + /// backreferences, trailing backslashes) will be recorded as a non-empty + /// string. + std::string sub(StringRef Repl, StringRef String, std::string *Error = 0); + private: struct llvm_regex *preg; int error; Modified: llvm/trunk/lib/Support/Regex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Regex.cpp?rev=96503&r1=96502&r2=96503&view=diff ============================================================================== --- llvm/trunk/lib/Support/Regex.cpp (original) +++ llvm/trunk/lib/Support/Regex.cpp Wed Feb 17 14:08:42 2010 @@ -90,3 +90,79 @@ return true; } + +std::string Regex::sub(StringRef Repl, StringRef String, + std::string *Error) { + SmallVector Matches; + + // Reset error, if given. + if (Error && !Error->empty()) *Error = ""; + + // Return the input if there was no match. + if (!match(String, &Matches)) + return String; + + // Otherwise splice in the replacement string, starting with the prefix before + // the match. + std::string Res(String.begin(), Matches[0].begin()); + + // Then the replacement string, honoring possible substitutions. + while (!Repl.empty()) { + // Skip to the next escape. + std::pair Split = Repl.split('\\'); + + // Add the skipped substring. + Res += Split.first; + + // Check for terminimation and trailing backslash. + if (Split.second.empty()) { + if (Repl.size() != Split.first.size() && + Error && Error->empty()) + *Error = "replacement string contained trailing backslash"; + break; + } + + // Otherwise update the replacement string and interpret escapes. + Repl = Split.second; + + // FIXME: We should have a StringExtras function for mapping C99 escapes. + switch (Repl[0]) { + // Treat all unrecognized characters as self-quoting. + default: + Res += Repl[0]; + Repl = Repl.substr(1); + break; + + // Single character escapes. + case 't': + Res += '\t'; + Repl = Repl.substr(1); + break; + case 'n': + Res += '\n'; + Repl = Repl.substr(1); + break; + + // Decimal escapes are backreferences. + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': { + // Extract the backreference number. + StringRef Ref = Repl.slice(0, Repl.find_first_not_of("0123456789")); + Repl = Repl.substr(Ref.size()); + + unsigned RefValue; + if (!Ref.getAsInteger(10, RefValue) && + RefValue < Matches.size()) + Res += Matches[RefValue]; + else if (Error && Error->empty()) + *Error = "invalid backreference string '" + Ref.str() + "'"; + break; + } + } + } + + // And finally the suffix. + Res += StringRef(Matches[0].end(), String.end() - Matches[0].end()); + + return Res; +} Modified: llvm/trunk/unittests/Support/RegexTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/RegexTest.cpp?rev=96503&r1=96502&r2=96503&view=diff ============================================================================== --- llvm/trunk/unittests/Support/RegexTest.cpp (original) +++ llvm/trunk/unittests/Support/RegexTest.cpp Wed Feb 17 14:08:42 2010 @@ -62,4 +62,33 @@ EXPECT_TRUE(r5.match(String)); } +TEST_F(RegexTest, Substitution) { + std::string Error; + + EXPECT_EQ("aNUMber", Regex("[0-9]+").sub("NUM", "a1234ber")); + + // Standard Escapes + EXPECT_EQ("a\\ber", Regex("[0-9]+").sub("\\\\", "a1234ber", &Error)); + EXPECT_EQ(Error, ""); + EXPECT_EQ("a\nber", Regex("[0-9]+").sub("\\n", "a1234ber", &Error)); + EXPECT_EQ(Error, ""); + EXPECT_EQ("a\tber", Regex("[0-9]+").sub("\\t", "a1234ber", &Error)); + EXPECT_EQ(Error, ""); + EXPECT_EQ("ajber", Regex("[0-9]+").sub("\\j", "a1234ber", &Error)); + EXPECT_EQ(Error, ""); + + EXPECT_EQ("aber", Regex("[0-9]+").sub("\\", "a1234ber", &Error)); + EXPECT_EQ(Error, "replacement string contained trailing backslash"); + + // Backreferences + EXPECT_EQ("aa1234bber", Regex("a[0-9]+b").sub("a\\0b", "a1234ber", &Error)); + EXPECT_EQ(Error, ""); + + EXPECT_EQ("a1234ber", Regex("a([0-9]+)b").sub("a\\1b", "a1234ber", &Error)); + EXPECT_EQ(Error, ""); + + EXPECT_EQ("aber", Regex("a[0-9]+b").sub("a\\100b", "a1234ber", &Error)); + EXPECT_EQ(Error, "invalid backreference string '100'"); +} + } From stoklund at 2pi.dk Wed Feb 17 14:18:50 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 17 Feb 2010 20:18:50 -0000 Subject: [llvm-commits] [llvm] r96504 - /llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Message-ID: <201002172018.o1HKIoUW026193@zion.cs.uiuc.edu> Author: stoklund Date: Wed Feb 17 14:18:50 2010 New Revision: 96504 URL: http://llvm.org/viewvc/llvm-project?rev=96504&view=rev Log: Remember to define super registers in mips calls. Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=96504&r1=96503&r2=96504&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Wed Feb 17 14:18:50 2010 @@ -300,9 +300,8 @@ // Jump and Link (Call) let isCall=1, hasDelaySlot=1, // All calls clobber the non-callee saved registers... - Defs = [AT, V0, V1, A0, A1, A2, A3, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, - K0, K1, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, - F14, F15, F16, F17, F18, F19], Uses = [GP] in { + Defs = [AT, V0, V1, A0, A1, A2, A3, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, + K0, K1, D0, D1, D2, D3, D4, D5, D6, D7, D8, D9], Uses = [GP] in { class JumpLink op, string instr_asm>: FJ< op, (outs), From greened at obbligato.org Wed Feb 17 14:21:42 2010 From: greened at obbligato.org (David Greene) Date: Wed, 17 Feb 2010 20:21:42 -0000 Subject: [llvm-commits] [llvm] r96505 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <201002172021.o1HKLgQZ026392@zion.cs.uiuc.edu> Author: greened Date: Wed Feb 17 14:21:42 2010 New Revision: 96505 URL: http://llvm.org/viewvc/llvm-project?rev=96505&view=rev Log: Make the non-temporal bit "significant" in MemSDNodes so they aren't CSE'd or otherwise combined with temporal MemSDNodes. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=96505&r1=96504&r2=96505&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Wed Feb 17 14:21:42 2010 @@ -1595,8 +1595,10 @@ return SubclassData; } + // We access subclass data here so that we can check consistency + // with MachineMemOperand information. bool isVolatile() const { return (SubclassData >> 5) & 1; } - bool isNonTemporal() const { return MMO->isNonTemporal(); } + bool isNonTemporal() const { return (SubclassData >> 6) & 1; } /// Returns the SrcValue and offset that describes the location of the access const Value *getSrcValue() const { return MMO->getValue(); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=96505&r1=96504&r2=96505&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Feb 17 14:21:42 2010 @@ -468,18 +468,20 @@ } /// encodeMemSDNodeFlags - Generic routine for computing a value for use in -/// the CSE map that carries volatility, indexing mode, and +/// the CSE map that carries volatility, temporalness, indexing mode, and /// extension/truncation information. /// static inline unsigned -encodeMemSDNodeFlags(int ConvType, ISD::MemIndexedMode AM, bool isVolatile) { +encodeMemSDNodeFlags(int ConvType, ISD::MemIndexedMode AM, bool isVolatile, + bool isNonTemporal) { assert((ConvType & 3) == ConvType && "ConvType may not require more than 2 bits!"); assert((AM & 7) == AM && "AM may not require more than 3 bits!"); return ConvType | (AM << 2) | - (isVolatile << 5); + (isVolatile << 5) | + (isNonTemporal << 6); } //===----------------------------------------------------------------------===// @@ -3845,7 +3847,8 @@ FoldingSetNodeID ID; AddNodeIDNode(ID, ISD::LOAD, VTs, Ops, 3); ID.AddInteger(MemVT.getRawBits()); - ID.AddInteger(encodeMemSDNodeFlags(ExtType, AM, MMO->isVolatile())); + ID.AddInteger(encodeMemSDNodeFlags(ExtType, AM, MMO->isVolatile(), + MMO->isNonTemporal())); void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) { cast(E)->refineAlignment(MMO); @@ -3926,7 +3929,8 @@ FoldingSetNodeID ID; AddNodeIDNode(ID, ISD::STORE, VTs, Ops, 4); ID.AddInteger(VT.getRawBits()); - ID.AddInteger(encodeMemSDNodeFlags(false, ISD::UNINDEXED, MMO->isVolatile())); + ID.AddInteger(encodeMemSDNodeFlags(false, ISD::UNINDEXED, MMO->isVolatile(), + MMO->isNonTemporal())); void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) { cast(E)->refineAlignment(MMO); @@ -3989,7 +3993,8 @@ FoldingSetNodeID ID; AddNodeIDNode(ID, ISD::STORE, VTs, Ops, 4); ID.AddInteger(SVT.getRawBits()); - ID.AddInteger(encodeMemSDNodeFlags(true, ISD::UNINDEXED, MMO->isVolatile())); + ID.AddInteger(encodeMemSDNodeFlags(true, ISD::UNINDEXED, MMO->isVolatile(), + MMO->isNonTemporal())); void *IP = 0; if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) { cast(E)->refineAlignment(MMO); @@ -5293,8 +5298,11 @@ MemSDNode::MemSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, EVT memvt, MachineMemOperand *mmo) : SDNode(Opc, dl, VTs), MemoryVT(memvt), MMO(mmo) { - SubclassData = encodeMemSDNodeFlags(0, ISD::UNINDEXED, MMO->isVolatile()); + SubclassData = encodeMemSDNodeFlags(0, ISD::UNINDEXED, MMO->isVolatile(), + MMO->isNonTemporal()); assert(isVolatile() == MMO->isVolatile() && "Volatile encoding error!"); + assert(isNonTemporal() == MMO->isNonTemporal() && + "Non-temporal encoding error!"); assert(memvt.getStoreSize() == MMO->getSize() && "Size mismatch!"); } @@ -5303,7 +5311,8 @@ MachineMemOperand *mmo) : SDNode(Opc, dl, VTs, Ops, NumOps), MemoryVT(memvt), MMO(mmo) { - SubclassData = encodeMemSDNodeFlags(0, ISD::UNINDEXED, MMO->isVolatile()); + SubclassData = encodeMemSDNodeFlags(0, ISD::UNINDEXED, MMO->isVolatile(), + MMO->isNonTemporal()); assert(isVolatile() == MMO->isVolatile() && "Volatile encoding error!"); assert(memvt.getStoreSize() == MMO->getSize() && "Size mismatch!"); } From johnny.chen at apple.com Wed Feb 17 15:39:10 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 17 Feb 2010 21:39:10 -0000 Subject: [llvm-commits] [llvm] r96519 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002172139.o1HLdAZ0032187@zion.cs.uiuc.edu> Author: johnny Date: Wed Feb 17 15:39:10 2010 New Revision: 96519 URL: http://llvm.org/viewvc/llvm-project?rev=96519&view=rev Log: Added RFE for disassembly only. B6.1.8 RFE Return From Exception loads the PC and the CPSR from the word at the specified address and the following word respectively. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96519&r1=96518&r2=96519&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Feb 17 15:39:10 2010 @@ -957,7 +957,7 @@ [/* For disassembly only; pattern left blank */]>; } -// Store Return State -- for disassembly only +// Store Return State is a system instruction -- for disassembly only def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode), NoItinerary, "srs${addr:submode}\tsp!, $mode", [/* For disassembly only; pattern left blank */]> { @@ -972,6 +972,21 @@ let Inst{22-20} = 0b100; // W = 0 } +// Return From Exception is a system instruction -- for disassembly only +def RFEW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base), + NoItinerary, "rfe${addr:submode}\t$base!", + [/* For disassembly only; pattern left blank */]> { + let Inst{31-28} = 0b1111; + let Inst{22-20} = 0b011; // W = 1 +} + +def RFE : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base), + NoItinerary, "rfe${addr:submode}\t$base", + [/* For disassembly only; pattern left blank */]> { + let Inst{31-28} = 0b1111; + let Inst{22-20} = 0b001; // W = 0 +} + //===----------------------------------------------------------------------===// // Load / store Instructions. // From bob.wilson at apple.com Wed Feb 17 16:23:12 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Feb 2010 22:23:12 -0000 Subject: [llvm-commits] [llvm] r96521 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <201002172223.o1HMNC60002281@zion.cs.uiuc.edu> Author: bwilson Date: Wed Feb 17 16:23:11 2010 New Revision: 96521 URL: http://llvm.org/viewvc/llvm-project?rev=96521&view=rev Log: More cleanup for NEON: * Use "S" abbreviation for scalar single FP registers in class and pattern names, instead of keeping the "D" (for "double") abbreviation and tacking on an "s" elsewhere in the name. * Move the scalar single FP register classes and patterns to be more consistent with other definitions in the file. * Rename "VNEGf32d" definition to "VNEGfd" for consistency. * Deleted the N2VDIntsPat pattern; N2VSPat is good enough. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=96521&r1=96520&r2=96521&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Wed Feb 17 16:23:11 2010 @@ -566,35 +566,34 @@ // Instruction Classes //===----------------------------------------------------------------------===// -// Basic 2-register operations, both double- and quad-register. +// Basic 2-register operations: single-, double- and quad-register. +class N2VS op24_23, bits<2> op21_20, bits<2> op19_18, + bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr, + string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode> + : N2V; class N2VD op24_23, bits<2> op21_20, bits<2> op19_18, - bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr,string Dt, - ValueType ResTy, ValueType OpTy, SDNode OpNode> + bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr, + string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode> : N2V; class N2VQ op24_23, bits<2> op21_20, bits<2> op19_18, - bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr,string Dt, - ValueType ResTy, ValueType OpTy, SDNode OpNode> + bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr, + string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode> : N2V; -// Basic 2-register operations, scalar single-precision. -class N2VDs op24_23, bits<2> op21_20, bits<2> op19_18, - bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr, - string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode> +// Basic 2-register intrinsics: single-, double- and quad-register. +class N2VSInt op24_23, bits<2> op21_20, bits<2> op19_18, + bits<2> op17_16, bits<5> op11_7, bit op4, + InstrItinClass itin, string OpcodeStr, string Dt, + ValueType ResTy, ValueType OpTy, Intrinsic IntOp> : N2V; - -class N2VDsPat - : NEONFPPat<(ResTy (OpNode SPR:$a)), - (EXTRACT_SUBREG (Inst (INSERT_SUBREG (OpTy (IMPLICIT_DEF)), - SPR:$a, arm_ssubreg_0)), - arm_ssubreg_0)>; - -// Basic 2-register intrinsics, both double- and quad-register. + (outs DPR_VFP2:$dst), (ins DPR_VFP2:$src), itin, + OpcodeStr, Dt, "$dst, $src", "", []>; class N2VDInt op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16, bits<5> op11_7, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, @@ -610,21 +609,6 @@ (ins QPR:$src), itin, OpcodeStr, Dt, "$dst, $src", "", [(set QPR:$dst, (ResTy (IntOp (OpTy QPR:$src))))]>; -// Basic 2-register intrinsics, scalar single-precision -class N2VDInts op24_23, bits<2> op21_20, bits<2> op19_18, - bits<2> op17_16, bits<5> op11_7, bit op4, - InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, Intrinsic IntOp> - : N2V; - -class N2VDIntsPat - : NEONFPPat<(f32 (OpNode SPR:$a)), - (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), - SPR:$a, arm_ssubreg_0)), - arm_ssubreg_0)>; - // Narrow 2-register intrinsics. class N2VNInt op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16, bits<5> op11_7, bit op6, bit op4, @@ -655,7 +639,16 @@ (ins QPR:$src1, QPR:$src2), itin, OpcodeStr, Dt, "$dst1, $dst2", "$src1 = $dst1, $src2 = $dst2", []>; -// Basic 3-register operations, both double- and quad-register. +// Basic 3-register operations: single-, double- and quad-register. +class N3VS op21_20, bits<4> op11_8, bit op4, + string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, + SDNode OpNode, bit Commutable> + : N3V { + let isCommutable = Commutable; +} + class N3VD op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode, bit Commutable> @@ -740,23 +733,6 @@ let isCommutable = 0; } -// Basic 3-register operations, scalar single-precision -class N3VDs op21_20, bits<4> op11_8, bit op4, - string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy, - SDNode OpNode, bit Commutable> - : N3V { - let isCommutable = Commutable; -} -class N3VDsPat - : NEONFPPat<(f32 (OpNode SPR:$a, SPR:$b)), - (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), - SPR:$a, arm_ssubreg_0), - (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), - SPR:$b, arm_ssubreg_0)), - arm_ssubreg_0)>; - // Basic 3-register intrinsics, both double- and quad-register. class N3VDInt op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, @@ -824,7 +800,15 @@ let isCommutable = 0; } -// Multiply-Add/Sub operations, both double- and quad-register. +// Multiply-Add/Sub operations: single-, double- and quad-register. +class N3VSMulOp op21_20, bits<4> op11_8, bit op4, + InstrItinClass itin, string OpcodeStr, string Dt, + ValueType Ty, SDNode MulOp, SDNode OpNode> + : N3V; + class N3VDMulOp op21_20, bits<4> op11_8, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, ValueType Ty, SDNode MulOp, SDNode OpNode> @@ -892,25 +876,6 @@ (ResTy (NEONvduplane (OpTy DPR_8:$src3), imm:$lane)))))))]>; -// Multiply-Add/Sub operations, scalar single-precision -class N3VDMulOps op21_20, bits<4> op11_8, bit op4, - InstrItinClass itin, string OpcodeStr, string Dt, - ValueType Ty, SDNode MulOp, SDNode OpNode> - : N3V; - -class N3VDMulOpsPat - : NEONFPPat<(f32 (OpNode SPR:$acc, (f32 (MulNode SPR:$a, SPR:$b)))), - (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), - SPR:$acc, arm_ssubreg_0), - (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), - SPR:$a, arm_ssubreg_0), - (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), - SPR:$b, arm_ssubreg_0)), - arm_ssubreg_0)>; - // Neon 3-argument intrinsics, both double- and quad-register. // The destination register is also used as the first source operand register. class N3VDInt3 op21_20, bits<4> op11_8, bit op4, @@ -2409,7 +2374,7 @@ def VNEGs32q : VNEGQ<0b10, "vneg", "s32", v4i32>; // VNEG : Vector Negate (floating-point) -def VNEGf32d : N2V<0b11, 0b11, 0b10, 0b01, 0b01111, 0, 0, +def VNEGfd : N2V<0b11, 0b11, 0b10, 0b01, 0b01111, 0, 0, (outs DPR:$dst), (ins DPR:$src), IIC_VUNAD, "vneg", "f32", "$dst, $src", "", [(set DPR:$dst, (v2f32 (fneg DPR:$src)))]>; @@ -2995,71 +2960,95 @@ // NEON instructions for single-precision FP math //===----------------------------------------------------------------------===// +class N2VSPat + : NEONFPPat<(ResTy (OpNode SPR:$a)), + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (OpTy (IMPLICIT_DEF)), + SPR:$a, arm_ssubreg_0)), + arm_ssubreg_0)>; + +class N3VSPat + : NEONFPPat<(f32 (OpNode SPR:$a, SPR:$b)), + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$a, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$b, arm_ssubreg_0)), + arm_ssubreg_0)>; + +class N3VSMulOpPat + : NEONFPPat<(f32 (OpNode SPR:$acc, (f32 (MulNode SPR:$a, SPR:$b)))), + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$acc, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$a, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), + SPR:$b, arm_ssubreg_0)), + arm_ssubreg_0)>; + // These need separate instructions because they must use DPR_VFP2 register // class which have SPR sub-registers. // Vector Add Operations used for single-precision FP let neverHasSideEffects = 1 in -def VADDfd_sfp : N3VDs<0,0,0b00,0b1101,0, "vadd", "f32", v2f32, v2f32, fadd, 1>; -def : N3VDsPat; +def VADDfd_sfp : N3VS<0,0,0b00,0b1101,0, "vadd", "f32", v2f32, v2f32, fadd, 1>; +def : N3VSPat; // Vector Sub Operations used for single-precision FP let neverHasSideEffects = 1 in -def VSUBfd_sfp : N3VDs<0,0,0b10,0b1101,0, "vsub", "f32", v2f32, v2f32, fsub, 0>; -def : N3VDsPat; +def VSUBfd_sfp : N3VS<0,0,0b10,0b1101,0, "vsub", "f32", v2f32, v2f32, fsub, 0>; +def : N3VSPat; // Vector Multiply Operations used for single-precision FP let neverHasSideEffects = 1 in -def VMULfd_sfp : N3VDs<1,0,0b00,0b1101,1, "vmul", "f32", v2f32, v2f32, fmul, 1>; -def : N3VDsPat; +def VMULfd_sfp : N3VS<1,0,0b00,0b1101,1, "vmul", "f32", v2f32, v2f32, fmul, 1>; +def : N3VSPat; // Vector Multiply-Accumulate/Subtract used for single-precision FP // vml[as].f32 can cause 4-8 cycle stalls in following ASIMD instructions, so // we want to avoid them for now. e.g., alternating vmla/vadd instructions. //let neverHasSideEffects = 1 in -//def VMLAfd_sfp : N3VDMulOps<0,0,0b00,0b1101,1, IIC_VMACD, "vmla", "f32", +//def VMLAfd_sfp : N3VSMulOp<0,0,0b00,0b1101,1, IIC_VMACD, "vmla", "f32", // v2f32, fmul, fadd>; -//def : N3VDMulOpsPat; +//def : N3VSMulOpPat; //let neverHasSideEffects = 1 in -//def VMLSfd_sfp : N3VDMulOps<0,0,0b10,0b1101,1, IIC_VMACD, "vmls", "f32", +//def VMLSfd_sfp : N3VSMulOp<0,0,0b10,0b1101,1, IIC_VMACD, "vmls", "f32", // v2f32, fmul, fsub>; -//def : N3VDMulOpsPat; +//def : N3VSMulOpPat; // Vector Absolute used for single-precision FP let neverHasSideEffects = 1 in -def VABSfd_sfp : N2VDInts<0b11, 0b11, 0b10, 0b01, 0b01110, 0, IIC_VUNAD, +def VABSfd_sfp : N2VSInt<0b11, 0b11, 0b10, 0b01, 0b01110, 0, IIC_VUNAD, "vabs", "f32", v2f32, v2f32, int_arm_neon_vabs>; -def : N2VDIntsPat; +def : N2VSPat; // Vector Negate used for single-precision FP let neverHasSideEffects = 1 in -def VNEGf32d_sfp : N2V<0b11, 0b11, 0b10, 0b01, 0b01111, 0, 0, - (outs DPR_VFP2:$dst), (ins DPR_VFP2:$src), IIC_VUNAD, - "vneg", "f32", "$dst, $src", "", []>; -def : N2VDIntsPat; +def VNEGfd_sfp : N2V<0b11, 0b11, 0b10, 0b01, 0b01111, 0, 0, + (outs DPR_VFP2:$dst), (ins DPR_VFP2:$src), IIC_VUNAD, + "vneg", "f32", "$dst, $src", "", []>; +def : N2VSPat; // Vector Convert between single-precision FP and integer let neverHasSideEffects = 1 in -def VCVTf2sd_sfp : N2VDs<0b11, 0b11, 0b10, 0b11, 0b01110, 0, "vcvt", "s32.f32", - v2i32, v2f32, fp_to_sint>; -def : N2VDsPat; +def VCVTf2sd_sfp : N2VS<0b11, 0b11, 0b10, 0b11, 0b01110, 0, "vcvt", "s32.f32", + v2i32, v2f32, fp_to_sint>; +def : N2VSPat; let neverHasSideEffects = 1 in -def VCVTf2ud_sfp : N2VDs<0b11, 0b11, 0b10, 0b11, 0b01111, 0, "vcvt", "u32.f32", - v2i32, v2f32, fp_to_uint>; -def : N2VDsPat; +def VCVTf2ud_sfp : N2VS<0b11, 0b11, 0b10, 0b11, 0b01111, 0, "vcvt", "u32.f32", + v2i32, v2f32, fp_to_uint>; +def : N2VSPat; let neverHasSideEffects = 1 in -def VCVTs2fd_sfp : N2VDs<0b11, 0b11, 0b10, 0b11, 0b01100, 0, "vcvt", "f32.s32", - v2f32, v2i32, sint_to_fp>; -def : N2VDsPat; +def VCVTs2fd_sfp : N2VS<0b11, 0b11, 0b10, 0b11, 0b01100, 0, "vcvt", "f32.s32", + v2f32, v2i32, sint_to_fp>; +def : N2VSPat; let neverHasSideEffects = 1 in -def VCVTu2fd_sfp : N2VDs<0b11, 0b11, 0b10, 0b11, 0b01101, 0, "vcvt", "f32.u32", - v2f32, v2i32, uint_to_fp>; -def : N2VDsPat; +def VCVTu2fd_sfp : N2VS<0b11, 0b11, 0b10, 0b11, 0b01101, 0, "vcvt", "f32.u32", + v2f32, v2i32, uint_to_fp>; +def : N2VSPat; //===----------------------------------------------------------------------===// // Non-Instruction Patterns From stoklund at 2pi.dk Wed Feb 17 16:23:27 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 17 Feb 2010 22:23:27 -0000 Subject: [llvm-commits] [test-suite] r96522 - /test-suite/trunk/External/SPEC/CINT95/Makefile Message-ID: <201002172223.o1HMNR1T002306@zion.cs.uiuc.edu> Author: stoklund Date: Wed Feb 17 16:23:27 2010 New Revision: 96522 URL: http://llvm.org/viewvc/llvm-project?rev=96522&view=rev Log: Disable the 126.gcc test for x86_64 This test is not 64-bit clean, and we already have similar gcc tests from SPEC2000 and SPEC2006. Modified: test-suite/trunk/External/SPEC/CINT95/Makefile Modified: test-suite/trunk/External/SPEC/CINT95/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/SPEC/CINT95/Makefile?rev=96522&r1=96521&r2=96522&view=diff ============================================================================== --- test-suite/trunk/External/SPEC/CINT95/Makefile (original) +++ test-suite/trunk/External/SPEC/CINT95/Makefile Wed Feb 17 16:23:27 2010 @@ -10,6 +10,7 @@ 147.vortex ifeq ($(ARCH),x86_64) +PARALLEL_DIRS := $(filter-out 126.gcc, $(PARALLEL_DIRS)) PARALLEL_DIRS := $(filter-out 147.vortex, $(PARALLEL_DIRS)) endif From johnny.chen at apple.com Wed Feb 17 16:37:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 17 Feb 2010 22:37:58 -0000 Subject: [llvm-commits] [llvm] r96523 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002172237.o1HMbw8A002904@zion.cs.uiuc.edu> Author: johnny Date: Wed Feb 17 16:37:58 2010 New Revision: 96523 URL: http://llvm.org/viewvc/llvm-project?rev=96523&view=rev Log: Added CLREX (Clear-Exclusive) for disassembly only. A8.6.30 Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96523&r1=96522&r2=96523&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Feb 17 16:37:58 2010 @@ -2039,6 +2039,14 @@ []>; } +// Clear-Exclusive is for disassembly only. +def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", + [/* For disassembly only; pattern left blank */]>, + Requires<[IsARM, HasV7]> { + let Inst{31-20} = 0xf57; + let Inst{7-4} = 0b0001; +} + // SWP/SWPB are deprecated in V6/V7 and for disassembly only. let mayLoad = 1 in { def SWP : AI<(outs GPR:$dst), (ins GPR:$src, GPR:$ptr), LdStExFrm, NoItinerary, From bob.wilson at apple.com Wed Feb 17 16:42:54 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Feb 2010 22:42:54 -0000 Subject: [llvm-commits] [llvm] r96525 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <201002172242.o1HMgsEw003235@zion.cs.uiuc.edu> Author: bwilson Date: Wed Feb 17 16:42:54 2010 New Revision: 96525 URL: http://llvm.org/viewvc/llvm-project?rev=96525&view=rev Log: Remove the NEON N2VSInt instruction class: it's only used in one place and since it has no pattern, there's not much point in distinguishing an "N2VS" class for intrinsics anyway. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=96525&r1=96524&r2=96525&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Wed Feb 17 16:42:54 2010 @@ -586,14 +586,7 @@ (ins QPR:$src), IIC_VUNAQ, OpcodeStr, Dt, "$dst, $src", "", [(set QPR:$dst, (ResTy (OpNode (OpTy QPR:$src))))]>; -// Basic 2-register intrinsics: single-, double- and quad-register. -class N2VSInt op24_23, bits<2> op21_20, bits<2> op19_18, - bits<2> op17_16, bits<5> op11_7, bit op4, - InstrItinClass itin, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy, Intrinsic IntOp> - : N2V; +// Basic 2-register intrinsics, both double- and quad-register. class N2VDInt op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16, bits<5> op11_7, bit op4, InstrItinClass itin, string OpcodeStr, string Dt, @@ -3018,8 +3011,9 @@ // Vector Absolute used for single-precision FP let neverHasSideEffects = 1 in -def VABSfd_sfp : N2VSInt<0b11, 0b11, 0b10, 0b01, 0b01110, 0, IIC_VUNAD, - "vabs", "f32", v2f32, v2f32, int_arm_neon_vabs>; +def VABSfd_sfp : N2V<0b11, 0b11, 0b10, 0b01, 0b01110, 0, 0, + (outs DPR_VFP2:$dst), (ins DPR_VFP2:$src), IIC_VUNAD, + "vabs", "f32", "$dst, $src", "", []>; def : N2VSPat; // Vector Negate used for single-precision FP From gohman at apple.com Wed Feb 17 16:47:06 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 22:47:06 -0000 Subject: [llvm-commits] [llvm] r96526 - in /llvm/trunk/docs: AdvancedGetElementPtr.html index.html Message-ID: <201002172247.o1HMl6ZI003439@zion.cs.uiuc.edu> Author: djg Date: Wed Feb 17 16:47:06 2010 New Revision: 96526 URL: http://llvm.org/viewvc/llvm-project?rev=96526&view=rev Log: Add an "advanced" GetElementPtr FAQ document, with answers to questions left unanswered by the first GetElementPtr FAQ. Added: llvm/trunk/docs/AdvancedGetElementPtr.html (with props) Modified: llvm/trunk/docs/index.html Added: llvm/trunk/docs/AdvancedGetElementPtr.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96526&view=auto ============================================================================== --- llvm/trunk/docs/AdvancedGetElementPtr.html (added) +++ llvm/trunk/docs/AdvancedGetElementPtr.html Wed Feb 17 16:47:06 2010 @@ -0,0 +1,356 @@ + + + + + The Revenge Of The Often Misunderstood GEP Instruction + + + + + +
+ The Revenge Of The Often Misunderstood GEP Instruction +
+ + + + +
+

GEP was mysterious and wily at first, but it turned out that the basic + workings were fairly comprehensible. However the dragon was merely subdued; + now it's back, and it has more fundamental complexity to confront. This + document seeks to uncover misunderstandings of the GEP operator that tend + to persist past initial confusion about the funky "extra 0" thing. Here we + show that the GEP instruction is really not quite as simple as it seems, + even after the initial confusion is overcome.

+
+ + + +
+

It's very similar; there are only subtle differences.

+ +

With ptrtoint, you have to pick an integer type. One approach is to pick i64; + this is safe on everything LLVM supports (LLVM internally assumes pointers + are never wider than 64 bits in many places), and the optimizer will actually + narrow the i64 arithmetic down to the actual pointer size on targets which + don't support 64-bit arithmetic in most cases. However, there are some cases + where it doesn't do this. With GEP you can avoid this problem. + +

Also, GEP carries additional pointer aliasing rules. It's invalid to take a + GEP from one object and address into a different separately allocated + object. IR producers (front-ends) must follow this rule, and consumers + (optimizers, specifically alias analysis) benefit from being able to rely + on it.

+ +

And, GEP is more concise in common cases.

+ +

However, for of the underlying integer computation implied, there + is no difference.

+ +
+ + + +
+

You don't. The integer computation implied by a GEP is target-independent. + Typically what you'll need to do is make your backend pattern-match + expressions trees involving ADD, MUL, etc., which are what GEP is lowered + into. This has the advantage of letting your code work correctly in more + cases.

+ +

GEP does use target-dependent parameters for the size and layout of data + types, which targets can customize.

+ +

If you require support for addressing units which are not 8 bits, you'll + need to fix a lot of code in the backend, with GEP lowering being only a + small piece of the overall picture.

+ +
+ + + +
+

The specific type i32 is probably just a historical artifact, however it's + wide enough for all practical purposes, so there's been no need to change it. + It doesn't necessarily imply i32 address arithmetic; it's just an identifier + which identifies a field in a struct. Requiring that all struct indices be + the same reduces the range of possibilities for cases where two GEPs are + effectively the same but have distinct operand types.

+ +
+ + + +
+

GEPs don't natively support VLAs. LLVM's type system is entirely static, + and GEP address computations are guided by an LLVM type.

+ +

VLA indices can be implemented as linearized indices. For example, an + expression like X[a][b][c], must be effectively lowered into a form + like X[a*m+b*n+c], so that it appears to the GEP as a single-dimensional + array reference.

+ +

This means if you want to write an analysis which understands array + indices and you want to support VLAs, your code will have to be + prepared to reverse-engineer the linearization. One way to solve this + problem is to use the ScalarEvolution library, which always presents + VLA and non-VLA indexing in the same manner.

+ +
+ + + +
+

There are two senses in which an array index can be out of bounds.

+ +

First, there's the array type which comes from the (static) type of + the first operand to the GEP. Indices greater than the number of elements + in the corresponding static array type are valid. There is no problem with + out of bounds indices in this sense. Indexing into an array only depends + on the size of the array element, not the number of elements.

+ +

A common example of how this is used is arrays where the size is not known. + It's common to use array types with zero length to represent these. The + fact that the static type says there are zero elements is irrelevant; it's + perfectly valid to compute arbitrary element indices, as the computation + only depends on the size of the array element, not the number of + elements. Note that zero-sized arrays are not a special case here.

+ +

This sense is unconnected with inbounds keyword. The + inbounds keyword is designed to describe low-level pointer + arithmetic overflow conditions, rather than high-level array + indexing rules. + +

Analysis passes which wish to understand array indexing should not + assume that the static array type bounds are respected.

+ +

The second sense of being out of bounds is computing an address that's + beyond of the actual underlying allocated object.

+ +

With the inbounds keyword, the result value of the GEP is + undefined if the address is outside the actual underlying allocated + object and not the address one-past-the-end.

+ +

Without the inbounds keyword, there are no restrictions + on computing out-of-bounds addresses. Obviously, performing a load or + a store requires an address of allocated and sufficiently aligned + memory. But the GEP itself is only concerned with computing addresses.

+ +
+ + + +
+

Yes. This is basically a special case of array indices being out + of bounds.

+ +
+ + + +
+

Yes. If both addresses are within the same allocated object, or + one-past-the-end, you'll get the comparison result you expect. If either + is outside of it, integer arithmetic wrapping may occur, so the + comparison may not be meaningful.

+ +
+ + + +
+

Yes. There are no restrictions on bitcasting a pointer value to an arbitrary + pointer type. The types in a GEP serve only to define the parameters for the + underlying integer computation. They need not correspond with the actual + type of the underlying object.

+ +

Furthermore, loads and stores don't have to use the same types as the type + of the underlying object. Types in this context serve only to specify + memory size and alignment. Beyond that there are merely a hint to the + optimizer indicating how the value will likely be used.

+ +
+ + + +
+

You can compute an address that way, but you can't use that pointer to + actually access the object if you do, unless the object is managed + outside of LLVM.

+ +

The underlying integer computation is sufficiently defined; null has a + defined value -- zero -- and you can add whatever value you want to it.

+ +

However, it's invalid to access (load from or store to) an LLVM-aware + object with such a pointer. This includes GlobalVariables, Allocas, and + objects pointed to by noalias pointers.

+ +
+ + + +
+

As with arithmetic on null, You can compute an address that way, but + you can't use that pointer to actually access the object if you do, + unless the object is managed outside of LLVM.

+ +
+ + + +
+

You can't do type-based alias analysis using LLVM's built-in type system, + because LLVM has no restrictions on mixing types in addressing, loads or + stores.

+ +

It would be possible to add special annotations to the IR, probably using + metadata, to describe a different type system (such as the C type system), + and do type-based aliasing on top of that. This is a much bigger + undertaking though.

+ +
+ + + + +
+

Some LLVM optimizers operate on GEPs by internally lowering them into + more primitive integer expressions, which allows them to be combined + with other integer expressions and/or split into multiple separate + integer expressions. If they've made non-trivial changes, translating + back into LLVM IR can involve reverse-engineering the structure of + the addressing in order to fit it into the static type of the original + first operand. It isn't always possibly to fully reconstruct this + structure; sometimes the underlying addressing doesn't correspond with + the static type at all. In such cases the optimizer instead will emit + a GEP with the base pointer casted to a simple address-unit pointer, + using the name "uglygep". This isn't pretty, but it's just as + valid, and it's sufficient to preserve the pointer aliasing guarantees + that GEP provides.

+ +
+ + + + +
+

Sort of. This hasn't always been forcefully disallowed, though it's + not recommended. It leads to awkward special cases in the optimizers. + In the future, it may be outright disallowed.

+ +

Instead, you should cast your pointer types and use arrays instead of + vectors for addressing. Arrays have the same in-memory representation + as vectors, so the addressing is interchangeable.

+ +
+ + + + +
+

Unknown.

+ +
+ + + + +
+

If the GEP has the inbounds keyword, the result value is + undefined.

+ +

Otherwise, the result value is the result from evaluating the implied + two's complement integer computation. However, since there's no + guarantee of where an object will be allocated in the address space, + such values have limited meaning.

+ +
+ + + + +
+

None, except that the address space qualifier on the first operand pointer + type always matches the address space qualifier on the result type.

+ +
+ + + + +
+

The design of GEP has the following goals, in rough unofficial + order of priority:

+

+

    +
  1. Support C, C-like languages, and languages which can be + conceptually lowered into C (this covers a lot).
  2. +
  3. Support optimizations such as those that are common in + C compilers.
  4. +
  5. Provide a consistent method for computing addresses so that + address computations don't need to be a part of load and + store instructions in the IR.
  6. +
  7. Support non-C-like languages, to the extent that it doesn't + interfere with other goals.
  8. +
  9. Minimize target-specific information in the IR.
  10. +
+

+
+ + + +
+
+ Valid CSS + Valid HTML 4.01 + The LLVM Compiler Infrastructure
+ Last modified: $Date$ +
+ + + Propchange: llvm/trunk/docs/AdvancedGetElementPtr.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: llvm/trunk/docs/index.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/index.html?rev=96526&r1=96525&r2=96526&view=diff ============================================================================== --- llvm/trunk/docs/index.html (original) +++ llvm/trunk/docs/index.html Wed Feb 17 16:47:06 2010 @@ -54,6 +54,9 @@ Multi-Stage Optimization - More details (quite old now).
  • GetElementPtr FAQ - Answers to some very frequent questions about LLVM's most frequently misunderstood instruction.
  • +
  • Advanced GetElementPtr FAQ - Answers +to questions about the GetElementPtr operator for those who have made it through +the first FAQ.
  • From gohman at apple.com Wed Feb 17 16:50:12 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 22:50:12 -0000 Subject: [llvm-commits] [llvm] r96527 - /llvm/trunk/docs/AdvancedGetElementPtr.html Message-ID: <201002172250.o1HMoC7Z003637@zion.cs.uiuc.edu> Author: djg Date: Wed Feb 17 16:50:12 2010 New Revision: 96527 URL: http://llvm.org/viewvc/llvm-project?rev=96527&view=rev Log: HTML validation fixes. Modified: llvm/trunk/docs/AdvancedGetElementPtr.html Modified: llvm/trunk/docs/AdvancedGetElementPtr.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96527&r1=96526&r2=96527&view=diff ============================================================================== --- llvm/trunk/docs/AdvancedGetElementPtr.html (original) +++ llvm/trunk/docs/AdvancedGetElementPtr.html Wed Feb 17 16:50:12 2010 @@ -324,20 +324,18 @@

    The design of GEP has the following goals, in rough unofficial order of priority:

    -

    -

      -
    1. Support C, C-like languages, and languages which can be - conceptually lowered into C (this covers a lot).
    2. -
    3. Support optimizations such as those that are common in - C compilers.
    4. -
    5. Provide a consistent method for computing addresses so that - address computations don't need to be a part of load and - store instructions in the IR.
    6. -
    7. Support non-C-like languages, to the extent that it doesn't - interfere with other goals.
    8. -
    9. Minimize target-specific information in the IR.
    10. -
    -

    +
      +
    1. Support C, C-like languages, and languages which can be + conceptually lowered into C (this covers a lot).
    2. +
    3. Support optimizations such as those that are common in + C compilers.
    4. +
    5. Provide a consistent method for computing addresses so that + address computations don't need to be a part of load and + store instructions in the IR.
    6. +
    7. Support non-C-like languages, to the extent that it doesn't + interfere with other goals.
    8. +
    9. Minimize target-specific information in the IR.
    10. +
    From gohman at apple.com Wed Feb 17 16:54:10 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Feb 2010 22:54:10 -0000 Subject: [llvm-commits] [llvm] r96528 - /llvm/trunk/docs/AdvancedGetElementPtr.html Message-ID: <201002172254.o1HMsAeD003924@zion.cs.uiuc.edu> Author: djg Date: Wed Feb 17 16:54:10 2010 New Revision: 96528 URL: http://llvm.org/viewvc/llvm-project?rev=96528&view=rev Log: Make this an unnumbered list. Modified: llvm/trunk/docs/AdvancedGetElementPtr.html Modified: llvm/trunk/docs/AdvancedGetElementPtr.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96528&r1=96527&r2=96528&view=diff ============================================================================== --- llvm/trunk/docs/AdvancedGetElementPtr.html (original) +++ llvm/trunk/docs/AdvancedGetElementPtr.html Wed Feb 17 16:54:10 2010 @@ -324,7 +324,7 @@

    The design of GEP has the following goals, in rough unofficial order of priority:

    -
      +
      • Support C, C-like languages, and languages which can be conceptually lowered into C (this covers a lot).
      • Support optimizations such as those that are common in @@ -335,7 +335,7 @@
      • Support non-C-like languages, to the extent that it doesn't interfere with other goals.
      • Minimize target-specific information in the IR.
      • -
    +
    From clattner at apple.com Wed Feb 17 17:10:10 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Feb 2010 15:10:10 -0800 Subject: [llvm-commits] [llvm] r96526 - in /llvm/trunk/docs: AdvancedGetElementPtr.html index.html In-Reply-To: <201002172247.o1HMl6ZI003439@zion.cs.uiuc.edu> References: <201002172247.o1HMl6ZI003439@zion.cs.uiuc.edu> Message-ID: <3FD716D2-E8AF-4506-8426-9DD4C170FC32@apple.com> On Feb 17, 2010, at 2:47 PM, Dan Gohman wrote: > Author: djg > Date: Wed Feb 17 16:47:06 2010 > New Revision: 96526 > > URL: http://llvm.org/viewvc/llvm-project?rev=96526&view=rev > Log: > Add an "advanced" GetElementPtr FAQ document, with answers to > questions left unanswered by the first GetElementPtr FAQ. Hi Dan, This sounds cool, but why not just add it to the end of the existing GEP document? -Chris > > Added: > llvm/trunk/docs/AdvancedGetElementPtr.html (with props) > Modified: > llvm/trunk/docs/index.html > > Added: llvm/trunk/docs/AdvancedGetElementPtr.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96526&view=auto > > ============================================================================== > --- llvm/trunk/docs/AdvancedGetElementPtr.html (added) > +++ llvm/trunk/docs/AdvancedGetElementPtr.html Wed Feb 17 16:47:06 2010 > @@ -0,0 +1,356 @@ > + + "http://www.w3.org/TR/html4/strict.dtd"> > + > + > + > + The Revenge Of The Often Misunderstood GEP Instruction > + > + > + > + > + > +
    > + The Revenge Of The Often Misunderstood GEP Instruction > +
    > + > + > + > + > +
    > +

    GEP was mysterious and wily at first, but it turned out that the basic > + workings were fairly comprehensible. However the dragon was merely subdued; > + now it's back, and it has more fundamental complexity to confront. This > + document seeks to uncover misunderstandings of the GEP operator that tend > + to persist past initial confusion about the funky "extra 0" thing. Here we > + show that the GEP instruction is really not quite as simple as it seems, > + even after the initial confusion is overcome.

    > +
    > + > + > + > +
    > +

    It's very similar; there are only subtle differences.

    > + > +

    With ptrtoint, you have to pick an integer type. One approach is to pick i64; > + this is safe on everything LLVM supports (LLVM internally assumes pointers > + are never wider than 64 bits in many places), and the optimizer will actually > + narrow the i64 arithmetic down to the actual pointer size on targets which > + don't support 64-bit arithmetic in most cases. However, there are some cases > + where it doesn't do this. With GEP you can avoid this problem. > + > +

    Also, GEP carries additional pointer aliasing rules. It's invalid to take a > + GEP from one object and address into a different separately allocated > + object. IR producers (front-ends) must follow this rule, and consumers > + (optimizers, specifically alias analysis) benefit from being able to rely > + on it.

    > + > +

    And, GEP is more concise in common cases.

    > + > +

    However, for of the underlying integer computation implied, there > + is no difference.

    > + > +
    > + > + > + > +
    > +

    You don't. The integer computation implied by a GEP is target-independent. > + Typically what you'll need to do is make your backend pattern-match > + expressions trees involving ADD, MUL, etc., which are what GEP is lowered > + into. This has the advantage of letting your code work correctly in more > + cases.

    > + > +

    GEP does use target-dependent parameters for the size and layout of data > + types, which targets can customize.

    > + > +

    If you require support for addressing units which are not 8 bits, you'll > + need to fix a lot of code in the backend, with GEP lowering being only a > + small piece of the overall picture.

    > + > +
    > + > + > + > +
    > +

    The specific type i32 is probably just a historical artifact, however it's > + wide enough for all practical purposes, so there's been no need to change it. > + It doesn't necessarily imply i32 address arithmetic; it's just an identifier > + which identifies a field in a struct. Requiring that all struct indices be > + the same reduces the range of possibilities for cases where two GEPs are > + effectively the same but have distinct operand types.

    > + > +
    > + > + > + > +
    > +

    GEPs don't natively support VLAs. LLVM's type system is entirely static, > + and GEP address computations are guided by an LLVM type.

    > + > +

    VLA indices can be implemented as linearized indices. For example, an > + expression like X[a][b][c], must be effectively lowered into a form > + like X[a*m+b*n+c], so that it appears to the GEP as a single-dimensional > + array reference.

    > + > +

    This means if you want to write an analysis which understands array > + indices and you want to support VLAs, your code will have to be > + prepared to reverse-engineer the linearization. One way to solve this > + problem is to use the ScalarEvolution library, which always presents > + VLA and non-VLA indexing in the same manner.

    > + > +
    > + > + > + > +
    > +

    There are two senses in which an array index can be out of bounds.

    > + > +

    First, there's the array type which comes from the (static) type of > + the first operand to the GEP. Indices greater than the number of elements > + in the corresponding static array type are valid. There is no problem with > + out of bounds indices in this sense. Indexing into an array only depends > + on the size of the array element, not the number of elements.

    > + > +

    A common example of how this is used is arrays where the size is not known. > + It's common to use array types with zero length to represent these. The > + fact that the static type says there are zero elements is irrelevant; it's > + perfectly valid to compute arbitrary element indices, as the computation > + only depends on the size of the array element, not the number of > + elements. Note that zero-sized arrays are not a special case here.

    > + > +

    This sense is unconnected with inbounds keyword. The > + inbounds keyword is designed to describe low-level pointer > + arithmetic overflow conditions, rather than high-level array > + indexing rules. > + > +

    Analysis passes which wish to understand array indexing should not > + assume that the static array type bounds are respected.

    > + > +

    The second sense of being out of bounds is computing an address that's > + beyond of the actual underlying allocated object.

    > + > +

    With the inbounds keyword, the result value of the GEP is > + undefined if the address is outside the actual underlying allocated > + object and not the address one-past-the-end.

    > + > +

    Without the inbounds keyword, there are no restrictions > + on computing out-of-bounds addresses. Obviously, performing a load or > + a store requires an address of allocated and sufficiently aligned > + memory. But the GEP itself is only concerned with computing addresses.

    > + > +
    > + > + > + > +
    > +

    Yes. This is basically a special case of array indices being out > + of bounds.

    > + > +
    > + > + > + > +
    > +

    Yes. If both addresses are within the same allocated object, or > + one-past-the-end, you'll get the comparison result you expect. If either > + is outside of it, integer arithmetic wrapping may occur, so the > + comparison may not be meaningful.

    > + > +
    > + > + > + > +
    > +

    Yes. There are no restrictions on bitcasting a pointer value to an arbitrary > + pointer type. The types in a GEP serve only to define the parameters for the > + underlying integer computation. They need not correspond with the actual > + type of the underlying object.

    > + > +

    Furthermore, loads and stores don't have to use the same types as the type > + of the underlying object. Types in this context serve only to specify > + memory size and alignment. Beyond that there are merely a hint to the > + optimizer indicating how the value will likely be used.

    > + > +
    > + > + > + > +
    > +

    You can compute an address that way, but you can't use that pointer to > + actually access the object if you do, unless the object is managed > + outside of LLVM.

    > + > +

    The underlying integer computation is sufficiently defined; null has a > + defined value -- zero -- and you can add whatever value you want to it.

    > + > +

    However, it's invalid to access (load from or store to) an LLVM-aware > + object with such a pointer. This includes GlobalVariables, Allocas, and > + objects pointed to by noalias pointers.

    > + > +
    > + > + > + > +
    > +

    As with arithmetic on null, You can compute an address that way, but > + you can't use that pointer to actually access the object if you do, > + unless the object is managed outside of LLVM.

    > + > +
    > + > + > + > +
    > +

    You can't do type-based alias analysis using LLVM's built-in type system, > + because LLVM has no restrictions on mixing types in addressing, loads or > + stores.

    > + > +

    It would be possible to add special annotations to the IR, probably using > + metadata, to describe a different type system (such as the C type system), > + and do type-based aliasing on top of that. This is a much bigger > + undertaking though.

    > + > +
    > + > + > + > + > +
    > +

    Some LLVM optimizers operate on GEPs by internally lowering them into > + more primitive integer expressions, which allows them to be combined > + with other integer expressions and/or split into multiple separate > + integer expressions. If they've made non-trivial changes, translating > + back into LLVM IR can involve reverse-engineering the structure of > + the addressing in order to fit it into the static type of the original > + first operand. It isn't always possibly to fully reconstruct this > + structure; sometimes the underlying addressing doesn't correspond with > + the static type at all. In such cases the optimizer instead will emit > + a GEP with the base pointer casted to a simple address-unit pointer, > + using the name "uglygep". This isn't pretty, but it's just as > + valid, and it's sufficient to preserve the pointer aliasing guarantees > + that GEP provides.

    > + > +
    > + > + > + > + > +
    > +

    Sort of. This hasn't always been forcefully disallowed, though it's > + not recommended. It leads to awkward special cases in the optimizers. > + In the future, it may be outright disallowed.

    > + > +

    Instead, you should cast your pointer types and use arrays instead of > + vectors for addressing. Arrays have the same in-memory representation > + as vectors, so the addressing is interchangeable.

    > + > +
    > + > + > + > + > +
    > +

    Unknown.

    > + > +
    > + > + > + > + > +
    > +

    If the GEP has the inbounds keyword, the result value is > + undefined.

    > + > +

    Otherwise, the result value is the result from evaluating the implied > + two's complement integer computation. However, since there's no > + guarantee of where an object will be allocated in the address space, > + such values have limited meaning.

    > + > +
    > + > + > + > + > +
    > +

    None, except that the address space qualifier on the first operand pointer > + type always matches the address space qualifier on the result type.

    > + > +
    > + > + > + > + > +
    > +

    The design of GEP has the following goals, in rough unofficial > + order of priority:

    > +

    > +

      > +
    1. Support C, C-like languages, and languages which can be > + conceptually lowered into C (this covers a lot).
    2. > +
    3. Support optimizations such as those that are common in > + C compilers.
    4. > +
    5. Provide a consistent method for computing addresses so that > + address computations don't need to be a part of load and > + store instructions in the IR.
    6. > +
    7. Support non-C-like languages, to the extent that it doesn't > + interfere with other goals.
    8. > +
    9. Minimize target-specific information in the IR.
    10. > +
    > +

    > +
    > + > + > + > +
    > +
    > + + src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"> > + + src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"> > + The LLVM Compiler Infrastructure
    > + Last modified: $Date$ > +
    > + > + > + > > Propchange: llvm/trunk/docs/AdvancedGetElementPtr.html > > ------------------------------------------------------------------------------ > svn:keywords = Author Date Id Revision > > Modified: llvm/trunk/docs/index.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/index.html?rev=96526&r1=96525&r2=96526&view=diff > > ============================================================================== > --- llvm/trunk/docs/index.html (original) > +++ llvm/trunk/docs/index.html Wed Feb 17 16:47:06 2010 > @@ -54,6 +54,9 @@ > Multi-Stage Optimization - More details (quite old now). >
  • GetElementPtr FAQ - Answers to some very > frequent questions about LLVM's most frequently misunderstood instruction.
  • > +
  • Advanced GetElementPtr FAQ - Answers > +to questions about the GetElementPtr operator for those who have made it through > +the first FAQ.
  • > > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Wed Feb 17 17:45:16 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 17 Feb 2010 23:45:16 -0000 Subject: [llvm-commits] [llvm] r96532 - /llvm/trunk/lib/MC/MCAssembler.cpp Message-ID: <201002172345.o1HNjGOo006483@zion.cs.uiuc.edu> Author: ddunbar Date: Wed Feb 17 17:45:16 2010 New Revision: 96532 URL: http://llvm.org/viewvc/llvm-project?rev=96532&view=rev Log: MC/Mach-O: Update fixup values for change to X86 offsets. Modified: llvm/trunk/lib/MC/MCAssembler.cpp Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=96532&r1=96531&r2=96532&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Wed Feb 17 17:45:16 2010 @@ -439,6 +439,7 @@ std::vector &Relocs) { uint32_t Address = Fragment.getOffset() + Fixup.Offset; unsigned IsPCRel = 0; + unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind); unsigned Type = RIT_Vanilla; // See . @@ -454,12 +455,10 @@ Value2 = SD->getFragment()->getAddress() + SD->getOffset(); } - unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind); - // The value which goes in the fixup is current value of the expression. Fixup.FixedValue = Value - Value2 + Target.getConstant(); if (isFixupKindPCRel(Fixup.Kind)) { - Fixup.FixedValue -= Address + (1 << Log2Size); + Fixup.FixedValue -= Address; IsPCRel = 1; } @@ -507,6 +506,7 @@ uint32_t Value = 0; unsigned Index = 0; unsigned IsPCRel = 0; + unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind); unsigned IsExtern = 0; unsigned Type = 0; @@ -544,10 +544,8 @@ // The value which goes in the fixup is current value of the expression. Fixup.FixedValue = Value + Target.getConstant(); - unsigned Log2Size = getFixupKindLog2Size(Fixup.Kind); - if (isFixupKindPCRel(Fixup.Kind)) { - Fixup.FixedValue -= Address + (1< Author: echristo Date: Wed Feb 17 17:55:26 2010 New Revision: 96533 URL: http://llvm.org/viewvc/llvm-project?rev=96533&view=rev Log: Fix a few unused parameter warnings. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/include/llvm/Pass.h llvm/trunk/include/llvm/Target/TargetMachine.h Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=96533&r1=96532&r2=96533&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Feb 17 17:55:26 2010 @@ -223,7 +223,7 @@ void EmitFunctionBody(); /// EmitInstruction - Targets should implement this to emit instructions. - virtual void EmitInstruction(const MachineInstr *MI) { + virtual void EmitInstruction(const MachineInstr *) { assert(0 && "EmitInstruction not implemented"); } Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=96533&r1=96532&r2=96533&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Wed Feb 17 17:55:26 2010 @@ -163,7 +163,7 @@ /// an analysis interface through multiple inheritance. If needed, it should /// override this to adjust the this pointer as needed for the specified pass /// info. - virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) { + virtual void *getAdjustedAnalysisPointer(const PassInfo *) { return this; } virtual ImmutablePass *getAsImmutablePass() { return 0; } Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=96533&r1=96532&r2=96533&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Wed Feb 17 17:55:26 2010 @@ -189,7 +189,7 @@ /// is not supported, or false on success. virtual bool addPassesToEmitFile(PassManagerBase &, formatted_raw_ostream &, - CodeGenFileType Filetype, + CodeGenFileType, CodeGenOpt::Level) { return true; } From johnny.chen at apple.com Wed Feb 17 18:19:08 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 18 Feb 2010 00:19:08 -0000 Subject: [llvm-commits] [llvm] r96540 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002180019.o1I0J8w8008300@zion.cs.uiuc.edu> Author: johnny Date: Wed Feb 17 18:19:08 2010 New Revision: 96540 URL: http://llvm.org/viewvc/llvm-project?rev=96540&view=rev Log: Added for disassembly only the variants of DMB, DSB, and ISB. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96540&r1=96539&r2=96540&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Feb 17 18:19:08 2010 @@ -1868,6 +1868,7 @@ Requires<[IsARM, HasV7]> { let Inst{31-4} = 0xf57ff05; // FIXME: add support for options other than a full system DMB + // See DMB disassembly-only variants below. let Inst{3-0} = 0b1111; } @@ -1878,6 +1879,7 @@ Requires<[IsARM, HasV7]> { let Inst{31-4} = 0xf57ff04; // FIXME: add support for options other than a full system DSB + // See DSB disassembly-only variants below. let Inst{3-0} = 0b1111; } @@ -1900,6 +1902,64 @@ } } +// Helper class for multiclass MemB -- for disassembly only +class AMBI + : AInoP<(outs), (ins), MiscFrm, NoItinerary, opc, asm, + [/* For disassembly only; pattern left blank */]>, + Requires<[IsARM, HasV7]> { + let Inst{31-20} = 0xf57; +} + +multiclass MemB op7_4, string opc> { + + def st : AMBI { + let Inst{7-4} = op7_4; + let Inst{3-0} = 0b1110; + } + + def ish : AMBI { + let Inst{7-4} = op7_4; + let Inst{3-0} = 0b1011; + } + + def ishst : AMBI { + let Inst{7-4} = op7_4; + let Inst{3-0} = 0b1010; + } + + def nsh : AMBI { + let Inst{7-4} = op7_4; + let Inst{3-0} = 0b0111; + } + + def nshst : AMBI { + let Inst{7-4} = op7_4; + let Inst{3-0} = 0b0110; + } + + def osh : AMBI { + let Inst{7-4} = op7_4; + let Inst{3-0} = 0b0011; + } + + def oshst : AMBI { + let Inst{7-4} = op7_4; + let Inst{3-0} = 0b0010; + } +} + +// These DMB variants are for disassembly only. +defm DMB : MemB<0b0101, "dmb">; + +// These DSB variants are for disassembly only. +defm DSB : MemB<0b0100, "dsb">; + +// ISB has only full system option -- for disassembly only +def ISBsy : AMBI<"isb", ""> { + let Inst{7-4} = 0b0110; + let Inst{3-0} = 0b1111; +} + let usesCustomInserter = 1 in { let Uses = [CPSR] in { def ATOMIC_LOAD_ADD_I8 : PseudoInst< From sabre at nondot.org Wed Feb 17 18:23:27 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Feb 2010 00:23:27 -0000 Subject: [llvm-commits] [llvm] r96541 - /llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Message-ID: <201002180023.o1I0NRAY008594@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 18:23:27 2010 New Revision: 96541 URL: http://llvm.org/viewvc/llvm-project?rev=96541&view=rev Log: fit in 80 cols Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96541&r1=96540&r2=96541&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Wed Feb 17 18:23:27 2010 @@ -1047,8 +1047,10 @@ "N->getDebugLoc(), MVT::Other, " "&InChains[0], InChains.size());"); if (GenDebug) { - emitCode("CurDAG->setSubgraphColor(" + ChainName +".getNode(), \"yellow\");"); - emitCode("CurDAG->setSubgraphColor(" + ChainName +".getNode(), \"black\");"); + emitCode("CurDAG->setSubgraphColor(" + ChainName + + ".getNode(), \"yellow\");"); + emitCode("CurDAG->setSubgraphColor(" + ChainName + + ".getNode(), \"black\");"); } } @@ -1755,15 +1757,17 @@ // Replace the emission code within selection routines with calls to the // emission functions. if (GenDebug) - GeneratedCode.push_back(std::make_pair(0, "CurDAG->setSubgraphColor(N, \"red\");")); - CallerCode = "SDNode *Result = Emit_" + utostr(EmitFuncNum) + CallerCode; + GeneratedCode.push_back(std::make_pair(0, + "CurDAG->setSubgraphColor(N, \"red\");")); + CallerCode = "SDNode *Result = Emit_" + utostr(EmitFuncNum) +CallerCode; GeneratedCode.push_back(std::make_pair(3, CallerCode)); if (GenDebug) { GeneratedCode.push_back(std::make_pair(0, "if(Result) {")); - GeneratedCode.push_back(std::make_pair(0, " CurDAG->setSubgraphColor(Result, \"yellow\");")); - GeneratedCode.push_back(std::make_pair(0, " CurDAG->setSubgraphColor(Result, \"black\");")); + GeneratedCode.push_back(std::make_pair(0, + " CurDAG->setSubgraphColor(Result, \"yellow\");")); + GeneratedCode.push_back(std::make_pair(0, + " CurDAG->setSubgraphColor(Result, \"black\");")); GeneratedCode.push_back(std::make_pair(0, "}")); - //GeneratedCode.push_back(std::make_pair(0, "CurDAG->setSubgraphColor(N, \"black\");")); } GeneratedCode.push_back(std::make_pair(0, "return Result;")); } From dpatel at apple.com Wed Feb 17 18:53:08 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 18 Feb 2010 00:53:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96543 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <201002180053.o1I0r8wb010237@zion.cs.uiuc.edu> Author: dpatel Date: Wed Feb 17 18:53:07 2010 New Revision: 96543 URL: http://llvm.org/viewvc/llvm-project?rev=96543&view=rev Log: Tidy up identification of "this" pointer argument and its type. Corresponding test case is test/FrontendC++/2010-02-17-DbgArtificialArg.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=96543&r1=96542&r2=96543&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Feb 17 18:53:07 2010 @@ -458,10 +458,13 @@ // Construct variable. DIScope VarScope = DIScope(cast(RegionStack.back())); + DIType Ty = getOrCreateType(type); + if (DECL_ARTIFICIAL (decl)) + Ty = DebugFactory.CreateArtificialType(Ty); llvm::DIVariable D = DebugFactory.CreateVariable(Tag, VarScope, Name, getOrCreateCompileUnit(Loc.file), - Loc.line, getOrCreateType(type)); + Loc.line, Ty); // Insert an llvm.dbg.declare into the current block. Instruction *Call = DebugFactory.InsertDeclare(AI, D, @@ -603,6 +606,21 @@ 0, 0, Encoding); } +/// isArtificialArgumentType - Return true if arg_type represents artificial, +/// i.e. "this" in c++, argument. +static bool isArtificialArgumentType(tree arg_type, tree method_type) { + if (TREE_CODE (method_type) != METHOD_TYPE) return false; + if (TREE_CODE (arg_type) != POINTER_TYPE) return false; + if (TREE_TYPE (arg_type) == TYPE_METHOD_BASETYPE (method_type)) + return true; + if (TYPE_MAIN_VARIANT (TREE_TYPE (arg_type)) + && TYPE_MAIN_VARIANT (TREE_TYPE (arg_type)) != TREE_TYPE (arg_type) + && (TYPE_MAIN_VARIANT (TREE_TYPE (arg_type)) + == TYPE_METHOD_BASETYPE (method_type))) + return true; + return false; +} + /// createMethodType - Create MethodType. DIType DebugInfo::createMethodType(tree type) { @@ -629,18 +647,18 @@ EltTys.push_back(getOrCreateType(TREE_TYPE(type))); // Set up remainder of arguments. + bool ProcessedFirstArg = false; for (tree arg = TYPE_ARG_TYPES(type); arg; arg = TREE_CHAIN(arg)) { tree formal_type = TREE_VALUE(arg); if (formal_type == void_type_node) break; llvm::DIType FormalType = getOrCreateType(formal_type); - if (TREE_CODE (type) == METHOD_TYPE - && TREE_CODE (formal_type) == POINTER_TYPE - && TREE_TYPE (formal_type) == TYPE_METHOD_BASETYPE (type)) { + if (!ProcessedFirstArg && isArtificialArgumentType(formal_type, type)) { DIType AFormalType = DebugFactory.CreateArtificialType(FormalType); EltTys.push_back(AFormalType); - TypeCache[formal_type] = WeakVH(AFormalType.getNode()); } else EltTys.push_back(FormalType); + if (!ProcessedFirstArg) + ProcessedFirstArg = true; } llvm::DIArray EltTypeArray = From dpatel at apple.com Wed Feb 17 18:53:49 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 18 Feb 2010 00:53:49 -0000 Subject: [llvm-commits] [llvm] r96544 - /llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp Message-ID: <201002180053.o1I0rncT010281@zion.cs.uiuc.edu> Author: dpatel Date: Wed Feb 17 18:53:49 2010 New Revision: 96544 URL: http://llvm.org/viewvc/llvm-project?rev=96544&view=rev Log: New test case for r96543. Added: llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp Added: llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2010-02-17-DbgArtificialArg.cpp?rev=96544&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp (added) +++ llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp Wed Feb 17 18:53:49 2010 @@ -0,0 +1,14 @@ +// RUN: %llvmgcc -g -S %s -o - | grep DW_TAG_pointer_type | grep "i32 458767, metadata .., metadata ..., metadata .., i32 0, i64 64, i64 64, i64 0, i32 64, metadata ..." +// Here, second to last argument "i32 64" indicates that artificial type is set. +// Test to artificial attribute attahed to "this" pointer type. +// Radar 7655792 and 7655002 + +class A { +public: + int fn1(int i) const { return i + 2; }; +}; + +int foo() { + A a; + return a.fn1(1); +} From evan.cheng at apple.com Wed Feb 17 20:13:50 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Feb 2010 02:13:50 -0000 Subject: [llvm-commits] [llvm] r96556 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/TargetLowering.cpp lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/critical-edge-split.ll test/CodeGen/X86/ins_subreg_coalesce-3.ll test/CodeGen/X86/omit-label.ll test/CodeGen/X86/trunc-to-bool.ll Message-ID: <201002180213.o1I2DphS014218@zion.cs.uiuc.edu> Author: evancheng Date: Wed Feb 17 20:13:50 2010 New Revision: 96556 URL: http://llvm.org/viewvc/llvm-project?rev=96556&view=rev Log: Some dag combiner goodness: Transform br (xor (x, y)) -> br (x != y) Transform br (xor (xor (x,y), 1)) -> br (x == y) Also normalize (and (X, 1) == / != 1 -> (and (X, 1)) != / == 0 to match to "test on x86" and "tst on arm" Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/critical-edge-split.ll llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll llvm/trunk/test/CodeGen/X86/omit-label.ll llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=96556&r1=96555&r2=96556&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Feb 17 20:13:50 2010 @@ -4655,7 +4655,8 @@ DAG.DeleteNode(Trunc); } // Replace the uses of SRL with SETCC - DAG.ReplaceAllUsesOfValueWith(N1, SetCC); + WorkListRemover DeadNodes(*this); + DAG.ReplaceAllUsesOfValueWith(N1, SetCC, &DeadNodes); removeFromWorkList(N1.getNode()); DAG.DeleteNode(N1.getNode()); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -4663,6 +4664,53 @@ } } } + + // Transform br(xor(x, y)) -> br(x != y) + // Transform br(xor(xor(x,y), 1)) -> br (x == y) + if (N1.hasOneUse() && N1.getOpcode() == ISD::XOR) { + SDNode *TheXor = N1.getNode(); + SDValue Op0 = TheXor->getOperand(0); + SDValue Op1 = TheXor->getOperand(1); + if (Op0.getOpcode() == Op1.getOpcode()) { + // Avoid missing important xor optimizations. + SDValue Tmp = visitXOR(TheXor); + if (Tmp.getNode()) { + DEBUG(dbgs() << "\nReplacing.8 "; + TheXor->dump(&DAG); + dbgs() << "\nWith: "; + Tmp.getNode()->dump(&DAG); + dbgs() << '\n'); + WorkListRemover DeadNodes(*this); + DAG.ReplaceAllUsesOfValueWith(N1, Tmp, &DeadNodes); + removeFromWorkList(TheXor); + DAG.DeleteNode(TheXor); + return DAG.getNode(ISD::BRCOND, N->getDebugLoc(), + MVT::Other, Chain, Tmp, N2); + } + } + + if (Op0.getOpcode() != ISD::SETCC && Op1.getOpcode() != ISD::SETCC) { + bool Equal = false; + if (ConstantSDNode *RHSCI = dyn_cast(Op0)) + if (RHSCI->getAPIntValue() == 1 && Op0.hasOneUse() && + Op0.getOpcode() == ISD::XOR) { + TheXor = Op0.getNode(); + Equal = true; + } + + SDValue SetCC = DAG.getSetCC(TheXor->getDebugLoc(), + TLI.getSetCCResultType(N1.getValueType()), + Op0, Op1, + Equal ? ISD::SETEQ : ISD::SETNE); + // Replace the uses of XOR with SETCC + WorkListRemover DeadNodes(*this); + DAG.ReplaceAllUsesOfValueWith(N1, SetCC, &DeadNodes); + removeFromWorkList(N1.getNode()); + DAG.DeleteNode(N1.getNode()); + return DAG.getNode(ISD::BRCOND, N->getDebugLoc(), + MVT::Other, Chain, SetCC, N2); + } + } return SDValue(); } @@ -5012,7 +5060,7 @@ assert(N->getValueType(2) == MVT::Other && "Malformed indexed loads?"); if (N->hasNUsesOfValue(0, 0) && N->hasNUsesOfValue(0, 1)) { SDValue Undef = DAG.getUNDEF(N->getValueType(0)); - DEBUG(dbgs() << "\nReplacing.6 "; + DEBUG(dbgs() << "\nReplacing.7 "; N->dump(&DAG); dbgs() << "\nWith: "; Undef.getNode()->dump(&DAG); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=96556&r1=96555&r2=96556&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Wed Feb 17 20:13:50 2010 @@ -1775,7 +1775,7 @@ break; // todo, be more careful with signed comparisons } } else if (N0.getOpcode() == ISD::SIGN_EXTEND_INREG && - (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { + (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { EVT ExtSrcTy = cast(N0.getOperand(1))->getVT(); unsigned ExtSrcTyBits = ExtSrcTy.getSizeInBits(); EVT ExtDstTy = N0.getValueType(); @@ -1809,7 +1809,6 @@ Cond); } else if ((N1C->isNullValue() || N1C->getAPIntValue() == 1) && (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { - // SETCC (SETCC), [0|1], [EQ|NE] -> SETCC if (N0.getOpcode() == ISD::SETCC) { bool TrueWhenTrue = (Cond == ISD::SETEQ) ^ (N1C->getAPIntValue() != 1); @@ -1822,9 +1821,9 @@ N0.getOperand(0).getValueType().isInteger()); return DAG.getSetCC(dl, VT, N0.getOperand(0), N0.getOperand(1), CC); } - + if ((N0.getOpcode() == ISD::XOR || - (N0.getOpcode() == ISD::AND && + (N0.getOpcode() == ISD::AND && N0.getOperand(0).getOpcode() == ISD::XOR && N0.getOperand(1) == N0.getOperand(0).getOperand(1))) && isa(N0.getOperand(1)) && @@ -1847,9 +1846,26 @@ N0.getOperand(0).getOperand(0), N0.getOperand(1)); } + return DAG.getSetCC(dl, VT, Val, N1, Cond == ISD::SETEQ ? ISD::SETNE : ISD::SETEQ); } + } else if (N1C->getAPIntValue() == 1) { + // If this is (X&1) == / != 1, normalize it to (X&1) != / == 0. + SDValue Op0 = N0; + if (Op0.getOpcode() == ISD::TRUNCATE) + Op0 = Op0.getOperand(0); + if (Op0.getOpcode() == ISD::AND && + isa(Op0.getOperand(1)) && + cast(Op0.getOperand(1))->getAPIntValue() == 1) { + if (Op0.getValueType() != VT) + Op0 = DAG.getNode(ISD::AND, dl, VT, + DAG.getNode(ISD::TRUNCATE, dl, VT, Op0.getOperand(0)), + DAG.getConstant(1, VT)); + return DAG.getSetCC(dl, VT, Op0, + DAG.getConstant(0, Op0.getValueType()), + Cond == ISD::SETEQ ? ISD::SETNE : ISD::SETEQ); + } } } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=96556&r1=96555&r2=96556&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Feb 17 20:13:50 2010 @@ -5874,26 +5874,31 @@ /// LowerToBT - Result of 'and' is compared against zero. Turn it into a BT node /// if it's possible. -static SDValue LowerToBT(SDValue Op0, ISD::CondCode CC, +static SDValue LowerToBT(SDValue And, ISD::CondCode CC, DebugLoc dl, SelectionDAG &DAG) { + SDValue Op0 = And.getOperand(0); + SDValue Op1 = And.getOperand(1); + if (Op0.getOpcode() == ISD::TRUNCATE) + Op0 = Op0.getOperand(0); + if (Op1.getOpcode() == ISD::TRUNCATE) + Op1 = Op1.getOperand(0); + SDValue LHS, RHS; - if (Op0.getOperand(1).getOpcode() == ISD::SHL) { - if (ConstantSDNode *Op010C = - dyn_cast(Op0.getOperand(1).getOperand(0))) - if (Op010C->getZExtValue() == 1) { - LHS = Op0.getOperand(0); - RHS = Op0.getOperand(1).getOperand(1); - } - } else if (Op0.getOperand(0).getOpcode() == ISD::SHL) { - if (ConstantSDNode *Op000C = - dyn_cast(Op0.getOperand(0).getOperand(0))) - if (Op000C->getZExtValue() == 1) { - LHS = Op0.getOperand(1); - RHS = Op0.getOperand(0).getOperand(1); - } - } else if (Op0.getOperand(1).getOpcode() == ISD::Constant) { - ConstantSDNode *AndRHS = cast(Op0.getOperand(1)); - SDValue AndLHS = Op0.getOperand(0); + if (Op1.getOpcode() == ISD::SHL) { + if (ConstantSDNode *And10C = dyn_cast(Op1.getOperand(0))) + if (And10C->getZExtValue() == 1) { + LHS = Op0; + RHS = Op1.getOperand(1); + } + } else if (Op0.getOpcode() == ISD::SHL) { + if (ConstantSDNode *And00C = dyn_cast(Op0.getOperand(0))) + if (And00C->getZExtValue() == 1) { + LHS = Op1; + RHS = Op0.getOperand(1); + } + } else if (Op1.getOpcode() == ISD::Constant) { + ConstantSDNode *AndRHS = cast(Op1); + SDValue AndLHS = Op0; if (AndRHS->getZExtValue() == 1 && AndLHS.getOpcode() == ISD::SRL) { LHS = AndLHS.getOperand(0); RHS = AndLHS.getOperand(1); @@ -5943,6 +5948,17 @@ return NewSetCC; } + // Look for "(setcc) == / != 1" to avoid unncessary setcc. + if (Op0.getOpcode() == X86ISD::SETCC && + Op1.getOpcode() == ISD::Constant && + cast(Op1)->getZExtValue() == 1 && + (CC == ISD::SETEQ || CC == ISD::SETNE)) { + X86::CondCode CCode = (X86::CondCode)Op0.getConstantOperandVal(0); + CCode = X86::GetOppositeBranchCondition(CCode); + return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, + DAG.getConstant(CCode, MVT::i8), Op0.getOperand(1)); + } + bool isFP = Op.getOperand(1).getValueType().isFloatingPoint(); unsigned X86CC = TranslateX86CC(CC, isFP, Op0, Op1, DAG); if (X86CC == X86::COND_INVALID) Modified: llvm/trunk/test/CodeGen/X86/critical-edge-split.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/critical-edge-split.ll?rev=96556&r1=96555&r2=96556&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/critical-edge-split.ll (original) +++ llvm/trunk/test/CodeGen/X86/critical-edge-split.ll Wed Feb 17 20:13:50 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin -tailcallopt=false -stats -info-output-file - | grep asm-printer | grep 31 +; RUN: llc < %s -mtriple=i386-apple-darwin -stats -info-output-file - | grep asm-printer | grep 29 %CC = type { %Register } %II = type { %"struct.XX::II::$_74" } Modified: llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll?rev=96556&r1=96555&r2=96556&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll Wed Feb 17 20:13:50 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86-64 | grep mov | count 5 +; RUN: llc < %s -march=x86-64 | grep mov | count 3 %struct.COMPOSITE = type { i8, i16, i16 } %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 } Modified: llvm/trunk/test/CodeGen/X86/omit-label.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/omit-label.ll?rev=96556&r1=96555&r2=96556&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/omit-label.ll (original) +++ llvm/trunk/test/CodeGen/X86/omit-label.ll Wed Feb 17 20:13:50 2010 @@ -1,57 +0,0 @@ -; RUN: llc < %s -asm-verbose=false -mtriple=x86_64-linux-gnu | FileCheck %s -; PR4126 -; PR4732 - -; Don't omit these labels' definitions. - -; CHECK: bux: -; CHECK: LBB1_1: - -define void @bux(i32 %p_53) nounwind optsize { -entry: - %0 = icmp eq i32 %p_53, 0 ; [#uses=1] - %1 = icmp sgt i32 %p_53, 0 ; [#uses=1] - %or.cond = and i1 %0, %1 ; [#uses=1] - br i1 %or.cond, label %bb.i, label %bb3 - -bb.i: ; preds = %entry - %2 = add i32 %p_53, 1 ; [#uses=1] - %3 = icmp slt i32 %2, 0 ; [#uses=0] - br label %bb3 - -bb3: ; preds = %bb.i, %entry - %4 = tail call i32 (...)* @baz(i32 0) nounwind ; [#uses=0] - ret void -} - -declare i32 @baz(...) - -; Don't omit this label in the assembly output. -; CHECK: int321: -; CHECK: LBB2_1 -; CHECK: LBB2_1 -; CHECK: LBB2_1: - -define void @int321(i8 signext %p_103, i32 %uint8p_104) nounwind readnone { -entry: - %tobool = icmp eq i8 %p_103, 0 ; [#uses=1] - %cmp.i = icmp sgt i8 %p_103, 0 ; [#uses=1] - %or.cond = and i1 %tobool, %cmp.i ; [#uses=1] - br i1 %or.cond, label %land.end.i, label %for.cond.preheader - -land.end.i: ; preds = %entry - %conv3.i = sext i8 %p_103 to i32 ; [#uses=1] - %div.i = sdiv i32 1, %conv3.i ; [#uses=1] - %tobool.i = icmp eq i32 %div.i, -2147483647 ; [#uses=0] - br label %for.cond.preheader - -for.cond.preheader: ; preds = %land.end.i, %entry - %cmp = icmp sgt i8 %p_103, 1 ; [#uses=1] - br i1 %cmp, label %for.end.split, label %for.cond - -for.cond: ; preds = %for.cond.preheader, %for.cond - br label %for.cond - -for.end.split: ; preds = %for.cond.preheader - ret void -} Modified: llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll?rev=96556&r1=96555&r2=96556&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll (original) +++ llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll Wed Feb 17 20:13:50 2010 @@ -3,13 +3,14 @@ ; value and as the operand of a branch. ; RUN: llc < %s -march=x86 | FileCheck %s -define i1 @test1(i32 %X) zeroext { +define i1 @test1(i32 %X) zeroext nounwind { %Y = trunc i32 %X to i1 ret i1 %Y } +; CHECK: test1: ; CHECK: andl $1, %eax -define i1 @test2(i32 %val, i32 %mask) { +define i1 @test2(i32 %val, i32 %mask) nounwind { entry: %shifted = ashr i32 %val, %mask %anded = and i32 %shifted, 1 @@ -20,9 +21,10 @@ ret_false: ret i1 false } -; CHECK: testb $1, %al +; CHECK: test2: +; CHECK: btl %eax -define i32 @test3(i8* %ptr) { +define i32 @test3(i8* %ptr) nounwind { %val = load i8* %ptr %tmp = trunc i8 %val to i1 br i1 %tmp, label %cond_true, label %cond_false @@ -31,9 +33,10 @@ cond_false: ret i32 42 } -; CHECK: testb $1, %al +; CHECK: test3: +; CHECK: testb $1, (%eax) -define i32 @test4(i8* %ptr) { +define i32 @test4(i8* %ptr) nounwind { %tmp = ptrtoint i8* %ptr to i1 br i1 %tmp, label %cond_true, label %cond_false cond_true: @@ -41,9 +44,10 @@ cond_false: ret i32 42 } -; CHECK: testb $1, %al +; CHECK: test4: +; CHECK: testb $1, 4(%esp) -define i32 @test6(double %d) { +define i32 @test5(double %d) nounwind { %tmp = fptosi double %d to i1 br i1 %tmp, label %cond_true, label %cond_false cond_true: @@ -51,4 +55,5 @@ cond_false: ret i32 42 } +; CHECK: test5: ; CHECK: testb $1 From jyasskin at google.com Wed Feb 17 20:36:02 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Thu, 18 Feb 2010 02:36:02 -0000 Subject: [llvm-commits] [llvm] r96559 - in /llvm/trunk: Makefile Makefile.config.in Makefile.rules autoconf/configure.ac configure test/Makefile test/Unit/lit.cfg test/Unit/lit.site.cfg.in tools/llvm-shlib/ tools/llvm-shlib/Makefile unittests/Makefile.unittest Message-ID: <201002180236.o1I2a3D2015337@zion.cs.uiuc.edu> Author: jyasskin Date: Wed Feb 17 20:36:02 2010 New Revision: 96559 URL: http://llvm.org/viewvc/llvm-project?rev=96559&view=rev Log: Add a shared library for LLVM, named libLLVM2.7svn.(so|dylib), and add an --enable-shared configure flag to have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll change to "2.7" in the release.) Always link the example programs shared to test that the shared library keeps working. On my mac laptop, Debug libLLVM2.7svn.dylib is 39MB, and opt (for example) is 16M static vs 440K shared. Two things are less than ideal here: 1) The library doesn't include any version information. Since we expect to break the ABI with every release, this shouldn't be much of a problem. If we do release a compatible 2.7.1, we may be able to hack its library to work with binaries compiled against 2.7.0, or we can just ask them to recompile. I'm hoping to get a real packaging expert to look at this for the 2.8 release. 2) llvm-config doesn't yet have an option to print link options for the shared library. I'll add this as a subsequent patch. Added: llvm/trunk/tools/llvm-shlib/ llvm/trunk/tools/llvm-shlib/Makefile Modified: llvm/trunk/Makefile llvm/trunk/Makefile.config.in llvm/trunk/Makefile.rules llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/test/Makefile llvm/trunk/test/Unit/lit.cfg llvm/trunk/test/Unit/lit.site.cfg.in llvm/trunk/unittests/Makefile.unittest Modified: llvm/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/Makefile (original) +++ llvm/trunk/Makefile Wed Feb 17 20:36:02 2010 @@ -30,8 +30,8 @@ DIRS := lib/System lib/Support utils OPTIONAL_DIRS := else - DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \ - tools runtime docs unittests + DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-shlib \ + tools/llvm-config tools runtime docs unittests OPTIONAL_DIRS := projects bindings endif Modified: llvm/trunk/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.config.in?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/Makefile.config.in (original) +++ llvm/trunk/Makefile.config.in Wed Feb 17 20:36:02 2010 @@ -266,6 +266,9 @@ # Do we want to build with position independent code? ENABLE_PIC := @ENABLE_PIC@ +# Do we want to link the tools shared? +ENABLE_SHARED := @ENABLE_SHARED@ + # Use -fvisibility-inlines-hidden? ENABLE_VISIBILITY_INLINES_HIDDEN := @ENABLE_VISIBILITY_INLINES_HIDDEN@ @@ -276,6 +279,9 @@ # Enable JIT for this platform TARGET_HAS_JIT = @TARGET_HAS_JIT@ +# Environment variable to set to change the runtime shared library search path. +SHLIBPATH_VAR = @SHLIBPATH_VAR@ + # Shared library extension for host platform. SHLIBEXT = @SHLIBEXT@ Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Wed Feb 17 20:36:02 2010 @@ -613,11 +613,12 @@ ifneq ($(HOST_OS),Darwin) ifneq ($(DARWIN_MAJVERS),4) ifdef TOOLNAME -ifdef EXAMPLE_TOOL - LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC) -else - LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC) -endif + LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib' + ifdef EXAMPLE_TOOL + LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC) + else + LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC) + endif endif endif endif @@ -952,11 +953,21 @@ $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG) +ifeq ($(ENABLE_SHARED), 1) +LLVMLibsOptions += -lLLVM$(LLVMVersion) +LLVMLibsPaths += $(LibDir)/libLLVM$(LLVMVersion)$(SHLIBEXT) +else +ifeq ($(EXAMPLE_TOOL), 1) +LLVMLibsOptions += -lLLVM$(LLVMVersion) +LLVMLibsPaths += $(LibDir)/libLLVM$(LLVMVersion)$(SHLIBEXT) +else LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS)) LLVMLibsPaths += $(LLVM_CONFIG) \ $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS)) endif endif +endif +endif ############################################################################### # Library Build Rules: Four ways to build a library @@ -1162,11 +1173,13 @@ # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to # building an archive. #--------------------------------------------------------- +ifndef NO_BUILD_ARCHIVE ifndef BUILD_ARCHIVE ifndef LOADABLE_MODULE BUILD_ARCHIVE = 1 endif endif +endif #--------------------------------------------------------- # Archive Library Targets: Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Wed Feb 17 20:36:02 2010 @@ -470,6 +470,18 @@ AC_DEFINE_UNQUOTED([ENABLE_PIC],$ENABLE_PIC, [Define if position independent code is enabled]) +dnl Allow linking tools against the shared library. +AC_ARG_ENABLE(shared, + AS_HELP_STRING([--enable-shared], + [Link LLVM tools shared (default is NO)]),, + enableval=default) +case "$enableval" in + yes) AC_SUBST(ENABLE_SHARED,[1]) ;; + no) AC_SUBST(ENABLE_SHARED,[0]) ;; + default) AC_SUBST(ENABLE_SHARED,[0]) ;; + *) AC_MSG_ERROR([Invalid setting for --enable-shared. Use "yes" or "no"]) ;; +esac + dnl Allow specific targets to be specified for building (or not) TARGETS_TO_BUILD="" AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets], @@ -1265,6 +1277,10 @@ dnl the Makefiles so we can use it there too AC_SUBST(SHLIBEXT,$libltdl_cv_shlibext) +dnl Propagate the run-time library path variable that the libltdl +dnl checks found to the Makefiles so we can use it there too +AC_SUBST(SHLIBPATH_VAR,$libltdl_cv_shlibpath_var) + # Translate the various configuration directories and other basic # information into substitutions that will end up in Makefile.config.in # that these configured values can be used by the makefiles Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Wed Feb 17 20:36:02 2010 @@ -689,6 +689,7 @@ ENABLE_DOXYGEN ENABLE_THREADS ENABLE_PIC +ENABLE_SHARED TARGETS_TO_BUILD LLVM_ENUM_TARGETS LLVM_ENUM_ASM_PRINTERS @@ -769,6 +770,7 @@ LLVMGCC_MAJVERS LLVMGCC_LANGS SHLIBEXT +SHLIBPATH_VAR LLVM_PREFIX LLVM_BINDIR LLVM_LIBDIR @@ -1401,6 +1403,7 @@ --enable-threads Use threads if available (default is YES) --enable-pic Build LLVM with Position Independent Code (default is YES) + --enable-shared Link LLVM tools shared (default is NO) --enable-targets Build specific host targets: all or target1,target2,... Valid targets are: host, x86, x86_64, sparc, powerpc, alpha, arm, mips, spu, @@ -4857,6 +4860,25 @@ _ACEOF +# Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then + enableval=$enable_shared; +else + enableval=default +fi + +case "$enableval" in + yes) ENABLE_SHARED=1 + ;; + no) ENABLE_SHARED=0 + ;; + default) ENABLE_SHARED=0 + ;; + *) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-shared. Use \"yes\" or \"no\"" >&5 +echo "$as_me: error: Invalid setting for --enable-shared. Use \"yes\" or \"no\"" >&2;} + { (exit 1); exit 1; }; } ;; +esac + TARGETS_TO_BUILD="" # Check whether --enable-targets was given. if test "${enable_targets+set}" = set; then @@ -11035,7 +11057,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <conf$$subs.sed <<_ACEOF +ENABLE_LLVMC_DYNAMIC!$ENABLE_LLVMC_DYNAMIC$ac_delim ENABLE_LLVMC_DYNAMIC_PLUGINS!$ENABLE_LLVMC_DYNAMIC_PLUGINS$ac_delim CXX!$CXX$ac_delim CXXFLAGS!$CXXFLAGS$ac_delim @@ -20773,6 +20799,7 @@ LLVMGCC_MAJVERS!$LLVMGCC_MAJVERS$ac_delim LLVMGCC_LANGS!$LLVMGCC_LANGS$ac_delim SHLIBEXT!$SHLIBEXT$ac_delim +SHLIBPATH_VAR!$SHLIBPATH_VAR$ac_delim LLVM_PREFIX!$LLVM_PREFIX$ac_delim LLVM_BINDIR!$LLVM_BINDIR$ac_delim LLVM_LIBDIR!$LLVM_LIBDIR$ac_delim @@ -20793,7 +20820,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 90; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: llvm/trunk/test/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Makefile?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/test/Makefile (original) +++ llvm/trunk/test/Makefile Wed Feb 17 20:36:02 2010 @@ -200,4 +200,6 @@ -e "s#@LLVM_TOOLS_DIR@#$(ToolDir)#g" \ -e "s#@LLVMGCCDIR@#$(LLVMGCCDIR)#g" \ -e "s#@LLVM_BUILD_MODE@#$(BuildMode)#g" \ + -e "s#@ENABLE_SHARED@#$(ENABLE_SHARED)#g" \ + -e "s#@SHLIBPATH_VAR@#$(SHLIBPATH_VAR)#g" \ $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@ Modified: llvm/trunk/test/Unit/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Unit/lit.cfg?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/test/Unit/lit.cfg (original) +++ llvm/trunk/test/Unit/lit.cfg Wed Feb 17 20:36:02 2010 @@ -23,7 +23,14 @@ ### -import os +# If necessary, point the dynamic loader at libLLVM.so. +if config.enable_shared: + libdir = os.path.join(config.llvm_obj_root, config.llvm_build_mode, 'lib') + shlibpath = config.environment.get(config.shlibpath_var,'') + if shlibpath: + shlibpath = ':' + shlibpath + shlibpath = libdir + shlibpath + config.environment[config.shlibpath_var] = shlibpath # Check that the object root is known. if config.test_exec_root is None: Modified: llvm/trunk/test/Unit/lit.site.cfg.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Unit/lit.site.cfg.in?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/test/Unit/lit.site.cfg.in (original) +++ llvm/trunk/test/Unit/lit.site.cfg.in Wed Feb 17 20:36:02 2010 @@ -5,6 +5,8 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvmgcc_dir = "@LLVMGCCDIR@" config.llvm_build_mode = "@LLVM_BUILD_MODE@" +config.enable_shared = @ENABLE_SHARED@ +config.shlibpath_var = "@SHLIBPATH_VAR@" # Let the main config do the real work. lit.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg") Added: llvm/trunk/tools/llvm-shlib/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-shlib/Makefile?rev=96559&view=auto ============================================================================== --- llvm/trunk/tools/llvm-shlib/Makefile (added) +++ llvm/trunk/tools/llvm-shlib/Makefile Wed Feb 17 20:36:02 2010 @@ -0,0 +1,61 @@ +##===- tools/shlib/Makefile --------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +LIBRARYNAME = LLVM$(LLVMVersion) + +NO_BUILD_ARCHIVE = 1 +LINK_LIBS_IN_SHARED = 1 +SHARED_LIBRARY = 1 + +include $(LEVEL)/Makefile.common + +# Include all archives in libLLVM.(so|dylib) except the ones that have +# their own dynamic libraries. +Archives := $(wildcard $(LibDir)/libLLVM*.a) +SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT)) +IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives)) +LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%) +LLVMLibsPaths := $(IncludeInLibLlvm) + +$(LibName.SO): $(LLVMLibsPaths) + +ifeq ($(HOST_OS),Darwin) + # set dylib internal version number to llvmCore submission number + ifdef LLVM_SUBMIT_VERSION + LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \ + -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \ + -Wl,-compatibility_version -Wl,1 + endif + # Include everything from the .a's into the shared library. + LLVMLibsOptions := $(LLVMLibsOptions) \ + -Wl,-all_load + # extra options to override libtool defaults + LLVMLibsOptions := $(LLVMLibsOptions) \ + -avoid-version \ + -Wl,-dead_strip \ + -Wl,-seg1addr -Wl,0xE0000000 + + # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line + DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/') + ifneq ($(DARWIN_VERS),8) + LLVMLibsOptions := $(LLVMLibsOptions) \ + -Wl,-install_name \ + -Wl,"@executable_path/../lib/lib$(LIBRARYNAME)$(SHLIBEXT)" + endif +endif + +ifeq ($(HOST_OS), Linux) + # Include everything from the .a's into the shared library. + LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \ + -Wl,--no-whole-archive + # Don't allow unresolved symbols, and warn if we'll need to modify + # the text segment when loading libLLVM.so. + LLVMLibsOptions += -Wl,--no-undefined,--warn-shared-textrel +endif Modified: llvm/trunk/unittests/Makefile.unittest URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Makefile.unittest?rev=96559&r1=96558&r2=96559&view=diff ============================================================================== --- llvm/trunk/unittests/Makefile.unittest (original) +++ llvm/trunk/unittests/Makefile.unittest Wed Feb 17 20:36:02 2010 @@ -28,6 +28,10 @@ CPP.Flags += $(NO_VARIADIC_MACROS) TESTLIBS = -lGoogleTest -lUnitTestMain +ifeq ($(ENABLE_SHARED), 1) +Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)" +endif + $(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(Echo) Linking $(BuildMode) unit test $(TESTNAME) $(StripWarnMsg) $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \ @@ -38,6 +42,6 @@ all:: $(LLVMUnitTestExe) unitcheck:: $(LLVMUnitTestExe) - $(LLVMUnitTestExe) + $(Run.Shared) $(LLVMUnitTestExe) endif From jyasskin at google.com Wed Feb 17 20:41:56 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Wed, 17 Feb 2010 18:41:56 -0800 Subject: [llvm-commits] [PATCH] Shared library for LLVM (issue198059) In-Reply-To: References: <0016e64640dcdc5da0047ee1e48d@google.com> Message-ID: <5d44f72f1002171841n3a3b9160se1c23b30843167ad@mail.gmail.com> On Wed, Feb 17, 2010 at 11:38 AM, Chris Lattner wrote: > > On Feb 17, 2010, at 11:31 AM, Jeffrey Yasskin wrote: > >> Ping? > > This looks fine to me (though I can't review the lit changes), please name it llvm/tools/llvm-shlib though. ?FWIW, I'd rather get this in sooner rather than later in case any issues pop up. ?Would it also be possible to get a single test to verify that the library is working? > Thanks, I've renamed the directory and changed the examples to link shared by default. Committed as http://llvm.org/viewvc/llvm-project?view=rev&revision=96559. >> >> On Tue, Feb 9, 2010 at 9:58 AM, Jeffrey Yasskin wrote: >>> I've fixed the llvm-config problem: >>> http://codereview.appspot.com/download/issue198059_5012.diff >>> >>> On Fri, Feb 5, 2010 at 2:22 PM, ? wrote: >>>> Reviewers: llvm-commits_cs.uiuc.edu, >>>> >>>> Message: >>>> We've had requests from packagers in the Unladen Swallow merge PEP that >>>> we link shared against LLVM instead of statically. This patch builds a >>>> libLLVM2.7svn.(so|dylib) and adds an --enable-shared configure flag to >>>> have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll >>>> change to "2.7" in the release.) >>>> >>>> On my mac laptop, libLLVM2.7svn.dylib is 39MB, and opt (for example) is >>>> 15M static vs 440K shared. >>>> >>>> I know of two things that are less than ideal here: >>>> 1) llvm-config gets rebuilt on the second build from an empty objdir. >>>> It's noticing that libLLVM.dylib got created after it did and might have >>>> dependencies. I'm looking into how to fix this. >>>> 2) The library doesn't include any version information. Since we expect >>>> to break the ABI with every release, I don't expect this to be much of a >>>> problem. If we do release a compatible 2.7.1, we may be able to hack its >>>> library to work with binaries compiled against 2.7.0, or we can just ask >>>> them to recompile. I'm hoping to get a real packaging expert to look at >>>> this for the 2.8 release. >>>> >>>> Current patch at >>>> http://codereview.appspot.com/download/issue198059_3001.diff. >>>> >>>> Description: >>>> We've had requests from packagers in the Unladen Swallow merge PEP that >>>> we link shared against an LLVM instead of statically. This patch builds >>>> a libLLVM2.7svn.(so|dylib) and adds an --enable-shared configure flag to >>>> have the tools linked shared. (2.7svn is just $(LLVMVersion) so it'll >>>> change to "2.7" in the release.) >>>> >>>> On my mac laptop, libLLVM2.7svn.dylib is 39MB, and opt (for example) is >>>> 15M static vs 440K shared. >>>> >>>> I know of two things that are less than ideal here: >>>> 1) llvm-config gets rebuilt on the second build from an empty objdir. >>>> It's noticing that libLLVM.dylib got created after it did and might have >>>> dependencies. I'm looking into how to fix this. >>>> 2) The library doesn't include any version information. Since we expect >>>> to break the ABI with every release, I don't expect this to be much of a >>>> problem. If we do release a compatible 2.7.1, we may be able to hack its >>>> library to work with binaries compiled against 2.7.0, or we can just ask >>>> them to recompile. I'm hoping to get a real packaging expert to look at >>>> this for the 2.8 release. >>>> >>>> Fixes http://llvm.org/PR3201. >>>> >>>> Please review this at http://codereview.appspot.com/198059/show >>>> >>>> Affected files: >>>> ? M ? ? Makefile >>>> ? M ? ? Makefile.config.in >>>> ? M ? ? Makefile.rules >>>> ? M ? ? autoconf/configure.ac >>>> ? M ? ? configure >>>> ? M ? ? test/Makefile >>>> ? M ? ? test/Unit/lit.cfg >>>> ? M ? ? test/Unit/lit.site.cfg.in >>>> ? A ? ? tools/shlib/Makefile >>>> ? M ? ? unittests/Makefile.unittest >>>> >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>> >>> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- Namast?, Jeffrey Yasskin http://jeffrey.yasskin.info/ From jyasskin at google.com Wed Feb 17 20:42:09 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Wed, 17 Feb 2010 18:42:09 -0800 Subject: [llvm-commits] [PATCH] Shared library for LLVM (issue198059) In-Reply-To: References: <0016e64640dcdc5da0047ee1e48d@google.com> Message-ID: <5d44f72f1002171842n24848d23r43e1c2bf3931abd9@mail.gmail.com> On Wed, Feb 17, 2010 at 11:33 AM, Eric Christopher wrote: > > On Feb 17, 2010, at 11:31 AM, Jeffrey Yasskin wrote: > >> Ping? > > Looks reasonable to me. If you can not diff regenerated files next time that would be helpful :) Thanks, sorry about that. > Thanks! > > -eric > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- Namast?, Jeffrey Yasskin http://jeffrey.yasskin.info/ From sabre at nondot.org Wed Feb 17 20:49:24 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Feb 2010 02:49:24 -0000 Subject: [llvm-commits] [llvm] r96560 - in /llvm/trunk/utils/TableGen: DAGISelEmitter.cpp DAGISelMatcher.cpp DAGISelMatcher.h DAGISelMatcherEmitter.cpp DAGISelMatcherGen.cpp Message-ID: <201002180249.o1I2nOjg016000@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 20:49:24 2010 New Revision: 96560 URL: http://llvm.org/viewvc/llvm-project?rev=96560&view=rev Log: eliminate the MatcherNodeWithChild class, give the 'child' field to MatcherNode. Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96560&r1=96559&r2=96560&view=diff ============================================================================== (empty) Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96560&r1=96559&r2=96560&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Wed Feb 17 20:49:24 2010 @@ -22,7 +22,7 @@ OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n"; } -void MatcherNodeWithChild::printChild(raw_ostream &OS, unsigned indent) const { +void MatcherNode::printChild(raw_ostream &OS, unsigned indent) const { if (Child) return Child->print(OS, indent); OS.indent(indent) << "\n"; Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96560&r1=96559&r2=96560&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Wed Feb 17 20:49:24 2010 @@ -31,6 +31,7 @@ /// MatcherNode - Base class for all the the DAG ISel Matcher representation /// nodes. class MatcherNode { + OwningPtr Child; public: enum KindTy { EmitNode, @@ -54,19 +55,24 @@ CheckChainCompatible }; const KindTy Kind; - + protected: MatcherNode(KindTy K) : Kind(K) {} public: virtual ~MatcherNode() {} KindTy getKind() const { return Kind; } - + + MatcherNode *getChild() { return Child.get(); } + const MatcherNode *getChild() const { return Child.get(); } + void setChild(MatcherNode *C) { Child.reset(C); } static inline bool classof(const MatcherNode *) { return true; } virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0; void dump() const; +protected: + void printChild(raw_ostream &OS, unsigned indent) const; }; /// EmitNodeMatcherNode - This signals a successful match and generates a node. @@ -85,33 +91,15 @@ virtual void print(raw_ostream &OS, unsigned indent = 0) const; }; -/// MatcherNodeWithChild - Every node accept the final accept state has a child -/// that is executed after the node runs. This class captures this commonality. -class MatcherNodeWithChild : public MatcherNode { - OwningPtr Child; -public: - MatcherNodeWithChild(KindTy K) : MatcherNode(K) {} - - MatcherNode *getChild() { return Child.get(); } - const MatcherNode *getChild() const { return Child.get(); } - void setChild(MatcherNode *C) { Child.reset(C); } - - static inline bool classof(const MatcherNode *N) { - return N->getKind() != EmitNode; - } - -protected: - void printChild(raw_ostream &OS, unsigned indent) const; -}; /// PushMatcherNode - This pushes a failure scope on the stack and evaluates /// 'child'. If 'child' fails to match, it pops its scope and attempts to /// match 'Failure'. -class PushMatcherNode : public MatcherNodeWithChild { +class PushMatcherNode : public MatcherNode { OwningPtr Failure; public: PushMatcherNode(MatcherNode *child = 0, MatcherNode *failure = 0) - : MatcherNodeWithChild(Push), Failure(failure) { + : MatcherNode(Push), Failure(failure) { setChild(child); } @@ -127,13 +115,13 @@ }; /// RecordMatcherNode - Save the current node in the operand list. -class RecordMatcherNode : public MatcherNodeWithChild { +class RecordMatcherNode : public MatcherNode { /// WhatFor - This is a string indicating why we're recording this. This /// should only be used for comment generation not anything semantic. std::string WhatFor; public: RecordMatcherNode(const std::string &whatfor) - : MatcherNodeWithChild(Record), WhatFor(whatfor) {} + : MatcherNode(Record), WhatFor(whatfor) {} const std::string &getWhatFor() const { return WhatFor; } @@ -146,11 +134,11 @@ /// MoveChildMatcherNode - This tells the interpreter to move into the /// specified child node. -class MoveChildMatcherNode : public MatcherNodeWithChild { +class MoveChildMatcherNode : public MatcherNode { unsigned ChildNo; public: MoveChildMatcherNode(unsigned childNo) - : MatcherNodeWithChild(MoveChild), ChildNo(childNo) {} + : MatcherNode(MoveChild), ChildNo(childNo) {} unsigned getChildNo() const { return ChildNo; } @@ -163,10 +151,10 @@ /// MoveParentMatcherNode - This tells the interpreter to move to the parent /// of the current node. -class MoveParentMatcherNode : public MatcherNodeWithChild { +class MoveParentMatcherNode : public MatcherNode { public: MoveParentMatcherNode() - : MatcherNodeWithChild(MoveParent) {} + : MatcherNode(MoveParent) {} static inline bool classof(const MatcherNode *N) { return N->getKind() == MoveParent; @@ -178,11 +166,11 @@ /// CheckSameMatcherNode - This checks to see if this node is exactly the same /// node as the specified match that was recorded with 'Record'. This is used /// when patterns have the same name in them, like '(mul GPR:$in, GPR:$in)'. -class CheckSameMatcherNode : public MatcherNodeWithChild { +class CheckSameMatcherNode : public MatcherNode { unsigned MatchNumber; public: CheckSameMatcherNode(unsigned matchnumber) - : MatcherNodeWithChild(CheckSame), MatchNumber(matchnumber) {} + : MatcherNode(CheckSame), MatchNumber(matchnumber) {} unsigned getMatchNumber() const { return MatchNumber; } @@ -196,11 +184,11 @@ /// CheckPatternPredicateMatcherNode - This checks the target-specific predicate /// to see if the entire pattern is capable of matching. This predicate does /// not take a node as input. This is used for subtarget feature checks etc. -class CheckPatternPredicateMatcherNode : public MatcherNodeWithChild { +class CheckPatternPredicateMatcherNode : public MatcherNode { std::string Predicate; public: CheckPatternPredicateMatcherNode(StringRef predicate) - : MatcherNodeWithChild(CheckPatternPredicate), Predicate(predicate) {} + : MatcherNode(CheckPatternPredicate), Predicate(predicate) {} StringRef getPredicate() const { return Predicate; } @@ -213,11 +201,11 @@ /// CheckPredicateMatcherNode - This checks the target-specific predicate to /// see if the node is acceptable. -class CheckPredicateMatcherNode : public MatcherNodeWithChild { +class CheckPredicateMatcherNode : public MatcherNode { StringRef PredName; public: CheckPredicateMatcherNode(StringRef predname) - : MatcherNodeWithChild(CheckPredicate), PredName(predname) {} + : MatcherNode(CheckPredicate), PredName(predname) {} StringRef getPredicateName() const { return PredName; } @@ -231,11 +219,11 @@ /// CheckOpcodeMatcherNode - This checks to see if the current node has the /// specified opcode, if not it fails to match. -class CheckOpcodeMatcherNode : public MatcherNodeWithChild { +class CheckOpcodeMatcherNode : public MatcherNode { StringRef OpcodeName; public: CheckOpcodeMatcherNode(StringRef opcodename) - : MatcherNodeWithChild(CheckOpcode), OpcodeName(opcodename) {} + : MatcherNode(CheckOpcode), OpcodeName(opcodename) {} StringRef getOpcodeName() const { return OpcodeName; } @@ -248,11 +236,11 @@ /// CheckTypeMatcherNode - This checks to see if the current node has the /// specified type, if not it fails to match. -class CheckTypeMatcherNode : public MatcherNodeWithChild { +class CheckTypeMatcherNode : public MatcherNode { MVT::SimpleValueType Type; public: CheckTypeMatcherNode(MVT::SimpleValueType type) - : MatcherNodeWithChild(CheckType), Type(type) {} + : MatcherNode(CheckType), Type(type) {} MVT::SimpleValueType getType() const { return Type; } @@ -265,11 +253,11 @@ /// CheckIntegerMatcherNode - This checks to see if the current node is a /// ConstantSDNode with the specified integer value, if not it fails to match. -class CheckIntegerMatcherNode : public MatcherNodeWithChild { +class CheckIntegerMatcherNode : public MatcherNode { int64_t Value; public: CheckIntegerMatcherNode(int64_t value) - : MatcherNodeWithChild(CheckInteger), Value(value) {} + : MatcherNode(CheckInteger), Value(value) {} int64_t getValue() const { return Value; } @@ -282,11 +270,11 @@ /// CheckCondCodeMatcherNode - This checks to see if the current node is a /// CondCodeSDNode with the specified condition, if not it fails to match. -class CheckCondCodeMatcherNode : public MatcherNodeWithChild { +class CheckCondCodeMatcherNode : public MatcherNode { StringRef CondCodeName; public: CheckCondCodeMatcherNode(StringRef condcodename) - : MatcherNodeWithChild(CheckCondCode), CondCodeName(condcodename) {} + : MatcherNode(CheckCondCode), CondCodeName(condcodename) {} StringRef getCondCodeName() const { return CondCodeName; } @@ -299,11 +287,11 @@ /// CheckValueTypeMatcherNode - This checks to see if the current node is a /// VTSDNode with the specified type, if not it fails to match. -class CheckValueTypeMatcherNode : public MatcherNodeWithChild { +class CheckValueTypeMatcherNode : public MatcherNode { StringRef TypeName; public: CheckValueTypeMatcherNode(StringRef type_name) - : MatcherNodeWithChild(CheckValueType), TypeName(type_name) {} + : MatcherNode(CheckValueType), TypeName(type_name) {} StringRef getTypeName() const { return TypeName; } @@ -318,11 +306,11 @@ /// CheckComplexPatMatcherNode - This node runs the specified ComplexPattern on /// the current node. -class CheckComplexPatMatcherNode : public MatcherNodeWithChild { +class CheckComplexPatMatcherNode : public MatcherNode { const ComplexPattern &Pattern; public: CheckComplexPatMatcherNode(const ComplexPattern &pattern) - : MatcherNodeWithChild(CheckComplexPat), Pattern(pattern) {} + : MatcherNode(CheckComplexPat), Pattern(pattern) {} const ComplexPattern &getPattern() const { return Pattern; } @@ -335,11 +323,11 @@ /// CheckAndImmMatcherNode - This checks to see if the current node is an 'and' /// with something equivalent to the specified immediate. -class CheckAndImmMatcherNode : public MatcherNodeWithChild { +class CheckAndImmMatcherNode : public MatcherNode { int64_t Value; public: CheckAndImmMatcherNode(int64_t value) - : MatcherNodeWithChild(CheckAndImm), Value(value) {} + : MatcherNode(CheckAndImm), Value(value) {} int64_t getValue() const { return Value; } @@ -352,11 +340,11 @@ /// CheckOrImmMatcherNode - This checks to see if the current node is an 'and' /// with something equivalent to the specified immediate. -class CheckOrImmMatcherNode : public MatcherNodeWithChild { +class CheckOrImmMatcherNode : public MatcherNode { int64_t Value; public: CheckOrImmMatcherNode(int64_t value) - : MatcherNodeWithChild(CheckOrImm), Value(value) {} + : MatcherNode(CheckOrImm), Value(value) {} int64_t getValue() const { return Value; } @@ -369,10 +357,10 @@ /// CheckFoldableChainNodeMatcherNode - This checks to see if the current node /// (which defines a chain operand) is safe to fold into a larger pattern. -class CheckFoldableChainNodeMatcherNode : public MatcherNodeWithChild { +class CheckFoldableChainNodeMatcherNode : public MatcherNode { public: CheckFoldableChainNodeMatcherNode() - : MatcherNodeWithChild(CheckFoldableChainNode) {} + : MatcherNode(CheckFoldableChainNode) {} static inline bool classof(const MatcherNode *N) { return N->getKind() == CheckFoldableChainNode; @@ -383,11 +371,11 @@ /// CheckChainCompatibleMatcherNode - Verify that the current node's chain /// operand is 'compatible' with the specified recorded node's. -class CheckChainCompatibleMatcherNode : public MatcherNodeWithChild { +class CheckChainCompatibleMatcherNode : public MatcherNode { unsigned PreviousOp; public: CheckChainCompatibleMatcherNode(unsigned previousop) - : MatcherNodeWithChild(CheckChainCompatible), PreviousOp(previousop) {} + : MatcherNode(CheckChainCompatible), PreviousOp(previousop) {} unsigned getPreviousOp() const { return PreviousOp; } Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96560&r1=96559&r2=96560&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Wed Feb 17 20:49:24 2010 @@ -221,7 +221,7 @@ unsigned MatcherTableEmitter:: EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) { unsigned Size = 0; - while (1) { + while (N) { // Push is a special case since it is binary. if (const PushMatcherNode *PMN = dyn_cast(N)) { // We need to encode the child and the offset of the failure code before @@ -256,11 +256,9 @@ // If there are children of this node, iterate to them, otherwise we're // done. - if (const MatcherNodeWithChild *MNWC = dyn_cast(N)) - N = MNWC->getChild(); - else - return Size; + N = N->getChild(); } + return Size; } void MatcherTableEmitter::EmitPredicateFunctions() { Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96560&r1=96559&r2=96560&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Wed Feb 17 20:49:24 2010 @@ -35,11 +35,11 @@ SmallVector InputChains; /// Matcher - This is the top level of the generated matcher, the result. - MatcherNodeWithChild *Matcher; + MatcherNode *Matcher; /// CurPredicate - As we emit matcher nodes, this points to the latest check /// which should have future checks stuck into its child position. - MatcherNodeWithChild *CurPredicate; + MatcherNode *CurPredicate; public: MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp); @@ -49,10 +49,10 @@ void EmitMatcherCode(); - MatcherNodeWithChild *GetMatcher() const { return Matcher; } - MatcherNodeWithChild *GetCurPredicate() const { return CurPredicate; } + MatcherNode *GetMatcher() const { return Matcher; } + MatcherNode *GetCurPredicate() const { return CurPredicate; } private: - void AddMatcherNode(MatcherNodeWithChild *NewNode); + void AddMatcherNode(MatcherNode *NewNode); void InferPossibleTypes(); void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes); void EmitLeafMatchCode(const TreePatternNode *N); @@ -107,7 +107,7 @@ /// AddMatcherNode - Add a matcher node to the current graph we're building. -void MatcherGen::AddMatcherNode(MatcherNodeWithChild *NewNode) { +void MatcherGen::AddMatcherNode(MatcherNode *NewNode) { if (CurPredicate != 0) CurPredicate->setChild(NewNode); else @@ -388,7 +388,7 @@ EmitNodeMatcherNode *Result = new EmitNodeMatcherNode(Pattern); // Link it into the pattern. - if (MatcherNodeWithChild *Pred = Gen.GetCurPredicate()) { + if (MatcherNode *Pred = Gen.GetCurPredicate()) { Pred->setChild(Result); return Gen.GetMatcher(); } From sabre at nondot.org Wed Feb 17 20:53:41 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Feb 2010 02:53:41 -0000 Subject: [llvm-commits] [llvm] r96561 - in /llvm/trunk/utils/TableGen: DAGISelMatcher.cpp DAGISelMatcher.h DAGISelMatcherEmitter.cpp DAGISelMatcherGen.cpp Message-ID: <201002180253.o1I2rfPS016185@zion.cs.uiuc.edu> Author: lattner Date: Wed Feb 17 20:53:41 2010 New Revision: 96561 URL: http://llvm.org/viewvc/llvm-project?rev=96561&view=rev Log: rename the child field to 'next'. This is not a parent/child relationship, this is a linear list relationship. Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96561&r1=96560&r2=96561&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Wed Feb 17 20:53:41 2010 @@ -22,98 +22,98 @@ OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n"; } -void MatcherNode::printChild(raw_ostream &OS, unsigned indent) const { - if (Child) - return Child->print(OS, indent); - OS.indent(indent) << "\n"; +void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const { + if (Next) + return Next->print(OS, indent); + OS.indent(indent) << "\n"; } void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "Push\n"; - printChild(OS, indent+2); + printNext(OS, indent+2); Failure->print(OS, indent); } void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "Record\n"; - printChild(OS, indent); + printNext(OS, indent); } void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "MoveChild " << ChildNo << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "MoveParent\n"; - printChild(OS, indent); + printNext(OS, indent); } void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckPatternPredicateMatcherNode:: print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckPredicate " << PredName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckInteger " << Value << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckAndImm " << Value << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckOrImm " << Value << '\n'; - printChild(OS, indent); + printNext(OS, indent); } void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckFoldableChainNode\n"; - printChild(OS, indent); + printNext(OS, indent); } void CheckChainCompatibleMatcherNode::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n"; - printChild(OS, indent); + printNext(OS, indent); } Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96561&r1=96560&r2=96561&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Wed Feb 17 20:53:41 2010 @@ -31,7 +31,9 @@ /// MatcherNode - Base class for all the the DAG ISel Matcher representation /// nodes. class MatcherNode { - OwningPtr Child; + // The next matcher node that is executed after this one. Null if this is the + // last stage of a match. + OwningPtr Next; public: enum KindTy { EmitNode, @@ -63,16 +65,16 @@ KindTy getKind() const { return Kind; } - MatcherNode *getChild() { return Child.get(); } - const MatcherNode *getChild() const { return Child.get(); } - void setChild(MatcherNode *C) { Child.reset(C); } + MatcherNode *getNext() { return Next.get(); } + const MatcherNode *getNext() const { return Next.get(); } + void setNext(MatcherNode *C) { Next.reset(C); } static inline bool classof(const MatcherNode *) { return true; } virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0; void dump() const; protected: - void printChild(raw_ostream &OS, unsigned indent) const; + void printNext(raw_ostream &OS, unsigned indent) const; }; /// EmitNodeMatcherNode - This signals a successful match and generates a node. @@ -93,14 +95,14 @@ /// PushMatcherNode - This pushes a failure scope on the stack and evaluates -/// 'child'. If 'child' fails to match, it pops its scope and attempts to +/// 'Next'. If 'Next' fails to match, it pops its scope and attempts to /// match 'Failure'. class PushMatcherNode : public MatcherNode { OwningPtr Failure; public: - PushMatcherNode(MatcherNode *child = 0, MatcherNode *failure = 0) + PushMatcherNode(MatcherNode *next = 0, MatcherNode *failure = 0) : MatcherNode(Push), Failure(failure) { - setChild(child); + setNext(next); } MatcherNode *getFailure() { return Failure.get(); } Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96561&r1=96560&r2=96561&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Wed Feb 17 20:53:41 2010 @@ -76,7 +76,7 @@ public: MatcherTableEmitter(formatted_raw_ostream &os) : OS(os) {} - unsigned EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent); + unsigned EmitMatcherList(const MatcherNode *N, unsigned Indent); void EmitPredicateFunctions(); private: @@ -217,9 +217,9 @@ return 0; } -/// EmitMatcherAndChildren - Emit the bytes for the specified matcher subtree. +/// EmitMatcherList - Emit the bytes for the specified matcher subtree. unsigned MatcherTableEmitter:: -EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) { +EmitMatcherList(const MatcherNode *N, unsigned Indent) { unsigned Size = 0; while (N) { // Push is a special case since it is binary. @@ -228,25 +228,25 @@ // emitting either of them. Handle this by buffering the output into a // string while we get the size. SmallString<128> TmpBuf; - unsigned ChildSize; + unsigned NextSize; { raw_svector_ostream OS(TmpBuf); formatted_raw_ostream FOS(OS); - ChildSize = - EmitMatcherAndChildren(cast(N)->getChild(),Indent+1); + NextSize = EmitMatcherList(cast(N)->getNext(), + Indent+1); } - if (ChildSize > 255) { + if (NextSize > 255) { errs() << "Tblgen internal error: can't handle predicate this complex yet\n"; exit(1); } OS.PadToColumn(Indent*2); - OS << "OPC_Push, " << ChildSize << ",\n"; + OS << "OPC_Push, " << NextSize << ",\n"; OS << TmpBuf.str(); - Size += 2 + ChildSize; + Size += 2 + NextSize; N = PMN->getFailure(); continue; @@ -254,9 +254,9 @@ Size += EmitMatcher(N, Indent); - // If there are children of this node, iterate to them, otherwise we're + // If there are other nodes in this list, iterate to them, otherwise we're // done. - N = N->getChild(); + N = N->getNext(); } return Size; } @@ -311,7 +311,7 @@ MatcherTableEmitter MatcherEmitter(OS); OS << " static const unsigned char MatcherTable[] = {\n"; - unsigned TotalSize = MatcherEmitter.EmitMatcherAndChildren(Matcher, 2); + unsigned TotalSize = MatcherEmitter.EmitMatcherList(Matcher, 2); OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n"; OS << "\n"; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96561&r1=96560&r2=96561&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Wed Feb 17 20:53:41 2010 @@ -38,7 +38,7 @@ MatcherNode *Matcher; /// CurPredicate - As we emit matcher nodes, this points to the latest check - /// which should have future checks stuck into its child position. + /// which should have future checks stuck into its Next position. MatcherNode *CurPredicate; public: MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp); @@ -109,7 +109,7 @@ /// AddMatcherNode - Add a matcher node to the current graph we're building. void MatcherGen::AddMatcherNode(MatcherNode *NewNode) { if (CurPredicate != 0) - CurPredicate->setChild(NewNode); + CurPredicate->setNext(NewNode); else Matcher = NewNode; CurPredicate = NewNode; @@ -389,7 +389,7 @@ // Link it into the pattern. if (MatcherNode *Pred = Gen.GetCurPredicate()) { - Pred->setChild(Result); + Pred->setNext(Result); return Gen.GetMatcher(); } From johnny.chen at apple.com Wed Feb 17 21:27:42 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 18 Feb 2010 03:27:42 -0000 Subject: [llvm-commits] [llvm] r96565 - in /llvm/trunk/lib/Target/ARM: ARMInstrFormats.td ARMInstrInfo.td Message-ID: <201002180327.o1I3RgMe018073@zion.cs.uiuc.edu> Author: johnny Date: Wed Feb 17 21:27:42 2010 New Revision: 96565 URL: http://llvm.org/viewvc/llvm-project?rev=96565&view=rev Log: Added LDRSBT, LDRHT, LDRSHT for disassembly only. And fixed encoding errors of AI3ldsbpo, AI3ldhpo, and AI3ldshpo in ARMInstrFormats.td in the process. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=96565&r1=96564&r2=96565&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Wed Feb 17 21:27:42 2010 @@ -734,7 +734,7 @@ let Inst{6} = 0; // S bit let Inst{7} = 1; let Inst{20} = 1; // L bit - let Inst{21} = 1; // W bit + let Inst{21} = 0; // W bit let Inst{24} = 0; // P bit let Inst{27-25} = 0b000; } @@ -747,7 +747,7 @@ let Inst{6} = 1; // S bit let Inst{7} = 1; let Inst{20} = 1; // L bit - let Inst{21} = 1; // W bit + let Inst{21} = 0; // W bit let Inst{24} = 0; // P bit let Inst{27-25} = 0b000; } @@ -760,7 +760,7 @@ let Inst{6} = 1; // S bit let Inst{7} = 1; let Inst{20} = 1; // L bit - let Inst{21} = 1; // W bit + let Inst{21} = 0; // W bit let Inst{24} = 0; // P bit let Inst{27-25} = 0b000; } Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96565&r1=96564&r2=96565&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Feb 17 21:27:42 2010 @@ -1069,7 +1069,7 @@ "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>; } -// LDRT and LDRBT are for disassembly only. +// LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only. def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb), (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru, @@ -1078,8 +1078,26 @@ } def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb), - (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru, - "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []> { + (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru, + "ldrbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> { + let Inst{21} = 1; // overwrite +} + +def LDRSBT : AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb), + (ins GPR:$base,am2offset:$offset), LdMiscFrm, IIC_iLoadru, + "ldrsbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> { + let Inst{21} = 1; // overwrite +} + +def LDRHT : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb), + (ins GPR:$base, am3offset:$offset), LdMiscFrm, IIC_iLoadru, + "ldrht", "\t$dst, [$base], $offset", "$base = $base_wb", []> { + let Inst{21} = 1; // overwrite +} + +def LDRSHT : AI3ldshpo<(outs GPR:$dst, GPR:$base_wb), + (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru, + "ldrsht", "\t$dst, [$base], $offset", "$base = $base_wb", []> { let Inst{21} = 1; // overwrite } From jyasskin at google.com Wed Feb 17 22:43:02 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Thu, 18 Feb 2010 04:43:02 -0000 Subject: [llvm-commits] [llvm] r96569 - in /llvm/trunk: Makefile Makefile.config.in Makefile.rules autoconf/configure.ac configure test/Makefile test/Unit/lit.cfg test/Unit/lit.site.cfg.in tools/llvm-shlib/ unittests/Makefile.unittest Message-ID: <201002180443.o1I4h31e021421@zion.cs.uiuc.edu> Author: jyasskin Date: Wed Feb 17 22:43:02 2010 New Revision: 96569 URL: http://llvm.org/viewvc/llvm-project?rev=96569&view=rev Log: Roll back the shared library, r96559. It broke two darwins and arm, mysteriously. Removed: llvm/trunk/tools/llvm-shlib/ Modified: llvm/trunk/Makefile llvm/trunk/Makefile.config.in llvm/trunk/Makefile.rules llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/test/Makefile llvm/trunk/test/Unit/lit.cfg llvm/trunk/test/Unit/lit.site.cfg.in llvm/trunk/unittests/Makefile.unittest Modified: llvm/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/Makefile (original) +++ llvm/trunk/Makefile Wed Feb 17 22:43:02 2010 @@ -30,8 +30,8 @@ DIRS := lib/System lib/Support utils OPTIONAL_DIRS := else - DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-shlib \ - tools/llvm-config tools runtime docs unittests + DIRS := lib/System lib/Support utils lib/VMCore lib tools/llvm-config \ + tools runtime docs unittests OPTIONAL_DIRS := projects bindings endif Modified: llvm/trunk/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.config.in?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/Makefile.config.in (original) +++ llvm/trunk/Makefile.config.in Wed Feb 17 22:43:02 2010 @@ -266,9 +266,6 @@ # Do we want to build with position independent code? ENABLE_PIC := @ENABLE_PIC@ -# Do we want to link the tools shared? -ENABLE_SHARED := @ENABLE_SHARED@ - # Use -fvisibility-inlines-hidden? ENABLE_VISIBILITY_INLINES_HIDDEN := @ENABLE_VISIBILITY_INLINES_HIDDEN@ @@ -279,9 +276,6 @@ # Enable JIT for this platform TARGET_HAS_JIT = @TARGET_HAS_JIT@ -# Environment variable to set to change the runtime shared library search path. -SHLIBPATH_VAR = @SHLIBPATH_VAR@ - # Shared library extension for host platform. SHLIBEXT = @SHLIBEXT@ Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Wed Feb 17 22:43:02 2010 @@ -613,12 +613,11 @@ ifneq ($(HOST_OS),Darwin) ifneq ($(DARWIN_MAJVERS),4) ifdef TOOLNAME - LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib' - ifdef EXAMPLE_TOOL - LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC) - else - LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC) - endif +ifdef EXAMPLE_TOOL + LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC) +else + LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC) +endif endif endif endif @@ -953,21 +952,11 @@ $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG) -ifeq ($(ENABLE_SHARED), 1) -LLVMLibsOptions += -lLLVM$(LLVMVersion) -LLVMLibsPaths += $(LibDir)/libLLVM$(LLVMVersion)$(SHLIBEXT) -else -ifeq ($(EXAMPLE_TOOL), 1) -LLVMLibsOptions += -lLLVM$(LLVMVersion) -LLVMLibsPaths += $(LibDir)/libLLVM$(LLVMVersion)$(SHLIBEXT) -else LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS)) LLVMLibsPaths += $(LLVM_CONFIG) \ $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS)) endif endif -endif -endif ############################################################################### # Library Build Rules: Four ways to build a library @@ -1173,13 +1162,11 @@ # If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to # building an archive. #--------------------------------------------------------- -ifndef NO_BUILD_ARCHIVE ifndef BUILD_ARCHIVE ifndef LOADABLE_MODULE BUILD_ARCHIVE = 1 endif endif -endif #--------------------------------------------------------- # Archive Library Targets: Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Wed Feb 17 22:43:02 2010 @@ -470,18 +470,6 @@ AC_DEFINE_UNQUOTED([ENABLE_PIC],$ENABLE_PIC, [Define if position independent code is enabled]) -dnl Allow linking tools against the shared library. -AC_ARG_ENABLE(shared, - AS_HELP_STRING([--enable-shared], - [Link LLVM tools shared (default is NO)]),, - enableval=default) -case "$enableval" in - yes) AC_SUBST(ENABLE_SHARED,[1]) ;; - no) AC_SUBST(ENABLE_SHARED,[0]) ;; - default) AC_SUBST(ENABLE_SHARED,[0]) ;; - *) AC_MSG_ERROR([Invalid setting for --enable-shared. Use "yes" or "no"]) ;; -esac - dnl Allow specific targets to be specified for building (or not) TARGETS_TO_BUILD="" AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets], @@ -1277,10 +1265,6 @@ dnl the Makefiles so we can use it there too AC_SUBST(SHLIBEXT,$libltdl_cv_shlibext) -dnl Propagate the run-time library path variable that the libltdl -dnl checks found to the Makefiles so we can use it there too -AC_SUBST(SHLIBPATH_VAR,$libltdl_cv_shlibpath_var) - # Translate the various configuration directories and other basic # information into substitutions that will end up in Makefile.config.in # that these configured values can be used by the makefiles Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Wed Feb 17 22:43:02 2010 @@ -689,7 +689,6 @@ ENABLE_DOXYGEN ENABLE_THREADS ENABLE_PIC -ENABLE_SHARED TARGETS_TO_BUILD LLVM_ENUM_TARGETS LLVM_ENUM_ASM_PRINTERS @@ -770,7 +769,6 @@ LLVMGCC_MAJVERS LLVMGCC_LANGS SHLIBEXT -SHLIBPATH_VAR LLVM_PREFIX LLVM_BINDIR LLVM_LIBDIR @@ -1403,7 +1401,6 @@ --enable-threads Use threads if available (default is YES) --enable-pic Build LLVM with Position Independent Code (default is YES) - --enable-shared Link LLVM tools shared (default is NO) --enable-targets Build specific host targets: all or target1,target2,... Valid targets are: host, x86, x86_64, sparc, powerpc, alpha, arm, mips, spu, @@ -4860,25 +4857,6 @@ _ACEOF -# Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then - enableval=$enable_shared; -else - enableval=default -fi - -case "$enableval" in - yes) ENABLE_SHARED=1 - ;; - no) ENABLE_SHARED=0 - ;; - default) ENABLE_SHARED=0 - ;; - *) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-shared. Use \"yes\" or \"no\"" >&5 -echo "$as_me: error: Invalid setting for --enable-shared. Use \"yes\" or \"no\"" >&2;} - { (exit 1); exit 1; }; } ;; -esac - TARGETS_TO_BUILD="" # Check whether --enable-targets was given. if test "${enable_targets+set}" = set; then @@ -11057,7 +11035,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <conf$$subs.sed <<_ACEOF -ENABLE_LLVMC_DYNAMIC!$ENABLE_LLVMC_DYNAMIC$ac_delim ENABLE_LLVMC_DYNAMIC_PLUGINS!$ENABLE_LLVMC_DYNAMIC_PLUGINS$ac_delim CXX!$CXX$ac_delim CXXFLAGS!$CXXFLAGS$ac_delim @@ -20799,7 +20773,6 @@ LLVMGCC_MAJVERS!$LLVMGCC_MAJVERS$ac_delim LLVMGCC_LANGS!$LLVMGCC_LANGS$ac_delim SHLIBEXT!$SHLIBEXT$ac_delim -SHLIBPATH_VAR!$SHLIBPATH_VAR$ac_delim LLVM_PREFIX!$LLVM_PREFIX$ac_delim LLVM_BINDIR!$LLVM_BINDIR$ac_delim LLVM_LIBDIR!$LLVM_LIBDIR$ac_delim @@ -20820,7 +20793,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 90; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: llvm/trunk/test/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Makefile?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/test/Makefile (original) +++ llvm/trunk/test/Makefile Wed Feb 17 22:43:02 2010 @@ -200,6 +200,4 @@ -e "s#@LLVM_TOOLS_DIR@#$(ToolDir)#g" \ -e "s#@LLVMGCCDIR@#$(LLVMGCCDIR)#g" \ -e "s#@LLVM_BUILD_MODE@#$(BuildMode)#g" \ - -e "s#@ENABLE_SHARED@#$(ENABLE_SHARED)#g" \ - -e "s#@SHLIBPATH_VAR@#$(SHLIBPATH_VAR)#g" \ $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@ Modified: llvm/trunk/test/Unit/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Unit/lit.cfg?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/test/Unit/lit.cfg (original) +++ llvm/trunk/test/Unit/lit.cfg Wed Feb 17 22:43:02 2010 @@ -23,14 +23,7 @@ ### -# If necessary, point the dynamic loader at libLLVM.so. -if config.enable_shared: - libdir = os.path.join(config.llvm_obj_root, config.llvm_build_mode, 'lib') - shlibpath = config.environment.get(config.shlibpath_var,'') - if shlibpath: - shlibpath = ':' + shlibpath - shlibpath = libdir + shlibpath - config.environment[config.shlibpath_var] = shlibpath +import os # Check that the object root is known. if config.test_exec_root is None: Modified: llvm/trunk/test/Unit/lit.site.cfg.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Unit/lit.site.cfg.in?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/test/Unit/lit.site.cfg.in (original) +++ llvm/trunk/test/Unit/lit.site.cfg.in Wed Feb 17 22:43:02 2010 @@ -5,8 +5,6 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvmgcc_dir = "@LLVMGCCDIR@" config.llvm_build_mode = "@LLVM_BUILD_MODE@" -config.enable_shared = @ENABLE_SHARED@ -config.shlibpath_var = "@SHLIBPATH_VAR@" # Let the main config do the real work. lit.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg") Modified: llvm/trunk/unittests/Makefile.unittest URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Makefile.unittest?rev=96569&r1=96568&r2=96569&view=diff ============================================================================== --- llvm/trunk/unittests/Makefile.unittest (original) +++ llvm/trunk/unittests/Makefile.unittest Wed Feb 17 22:43:02 2010 @@ -28,10 +28,6 @@ CPP.Flags += $(NO_VARIADIC_MACROS) TESTLIBS = -lGoogleTest -lUnitTestMain -ifeq ($(ENABLE_SHARED), 1) -Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)" -endif - $(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(Echo) Linking $(BuildMode) unit test $(TESTNAME) $(StripWarnMsg) $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \ @@ -42,6 +38,6 @@ all:: $(LLVMUnitTestExe) unitcheck:: $(LLVMUnitTestExe) - $(Run.Shared) $(LLVMUnitTestExe) + $(LLVMUnitTestExe) endif From bob.wilson at apple.com Thu Feb 18 00:05:54 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 18 Feb 2010 06:05:54 -0000 Subject: [llvm-commits] [llvm] r96572 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h lib/Target/ARM/ARMInstrNEON.td test/CodeGen/ARM/neon_minmax.ll Message-ID: <201002180605.o1I65sZb024836@zion.cs.uiuc.edu> Author: bwilson Date: Thu Feb 18 00:05:53 2010 New Revision: 96572 URL: http://llvm.org/viewvc/llvm-project?rev=96572&view=rev Log: Use NEON vmin/vmax instructions for floating-point selects. Radar 7461718. Added: llvm/trunk/test/CodeGen/ARM/neon_minmax.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=96572&r1=96571&r2=96572&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Feb 18 00:05:53 2010 @@ -294,6 +294,7 @@ setTargetDAGCombine(ISD::SIGN_EXTEND); setTargetDAGCombine(ISD::ZERO_EXTEND); setTargetDAGCombine(ISD::ANY_EXTEND); + setTargetDAGCombine(ISD::SELECT_CC); } computeRegisterProperties(); @@ -544,6 +545,8 @@ case ARMISD::VZIP: return "ARMISD::VZIP"; case ARMISD::VUZP: return "ARMISD::VUZP"; case ARMISD::VTRN: return "ARMISD::VTRN"; + case ARMISD::FMAX: return "ARMISD::FMAX"; + case ARMISD::FMIN: return "ARMISD::FMIN"; } } @@ -3856,23 +3859,97 @@ return SDValue(); } +/// PerformSELECT_CCCombine - Target-specific DAG combining for ISD::SELECT_CC +/// to match f32 max/min patterns to use NEON vmax/vmin instructions. +static SDValue PerformSELECT_CCCombine(SDNode *N, SelectionDAG &DAG, + const ARMSubtarget *ST) { + // If the target supports NEON, try to use vmax/vmin instructions for f32 + // selects like "x < y ? x : y". Unless the FiniteOnlyFPMath option is set, + // be careful about NaNs: NEON's vmax/vmin return NaN if either operand is + // a NaN; only do the transformation when it matches that behavior. + + // For now only do this when using NEON for FP operations; if using VFP, it + // is not obvious that the benefit outweighs the cost of switching to the + // NEON pipeline. + if (!ST->hasNEON() || !ST->useNEONForSinglePrecisionFP() || + N->getValueType(0) != MVT::f32) + return SDValue(); + + SDValue CondLHS = N->getOperand(0); + SDValue CondRHS = N->getOperand(1); + SDValue LHS = N->getOperand(2); + SDValue RHS = N->getOperand(3); + ISD::CondCode CC = cast(N->getOperand(4))->get(); + + unsigned Opcode = 0; + bool IsReversed; + if (LHS == CondLHS && RHS == CondRHS) { + IsReversed = false; // x CC y ? x : y + } else if (LHS == CondRHS && RHS == CondLHS) { + IsReversed = true ; // x CC y ? y : x + } else { + return SDValue(); + } + + switch (CC) { + default: break; + case ISD::SETOLT: + case ISD::SETOLE: + case ISD::SETLT: + case ISD::SETLE: + // This can be vmin if we can prove that the LHS is not a NaN. + // (If either operand is NaN, the comparison will be false and the result + // will be the RHS, which matches vmin if RHS is the NaN.) + if (DAG.isKnownNeverNaN(LHS)) + Opcode = IsReversed ? ARMISD::FMAX : ARMISD::FMIN; + break; + + case ISD::SETULT: + case ISD::SETULE: + // Likewise, for ULT/ULE we need to know that RHS is not a NaN. + if (DAG.isKnownNeverNaN(RHS)) + Opcode = IsReversed ? ARMISD::FMAX : ARMISD::FMIN; + break; + + case ISD::SETOGT: + case ISD::SETOGE: + case ISD::SETGT: + case ISD::SETGE: + // This can be vmax if we can prove that the LHS is not a NaN. + // (If either operand is NaN, the comparison will be false and the result + // will be the RHS, which matches vmax if RHS is the NaN.) + if (DAG.isKnownNeverNaN(LHS)) + Opcode = IsReversed ? ARMISD::FMIN : ARMISD::FMAX; + break; + + case ISD::SETUGT: + case ISD::SETUGE: + // Likewise, for UGT/UGE we need to know that RHS is not a NaN. + if (DAG.isKnownNeverNaN(RHS)) + Opcode = IsReversed ? ARMISD::FMIN : ARMISD::FMAX; + break; + } + + if (!Opcode) + return SDValue(); + return DAG.getNode(Opcode, N->getDebugLoc(), N->getValueType(0), LHS, RHS); +} + SDValue ARMTargetLowering::PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const { switch (N->getOpcode()) { default: break; - case ISD::ADD: return PerformADDCombine(N, DCI); - case ISD::SUB: return PerformSUBCombine(N, DCI); + case ISD::ADD: return PerformADDCombine(N, DCI); + case ISD::SUB: return PerformSUBCombine(N, DCI); case ARMISD::VMOVRRD: return PerformVMOVRRDCombine(N, DCI); - case ISD::INTRINSIC_WO_CHAIN: - return PerformIntrinsicCombine(N, DCI.DAG); + case ISD::INTRINSIC_WO_CHAIN: return PerformIntrinsicCombine(N, DCI.DAG); case ISD::SHL: case ISD::SRA: - case ISD::SRL: - return PerformShiftCombine(N, DCI.DAG, Subtarget); + case ISD::SRL: return PerformShiftCombine(N, DCI.DAG, Subtarget); case ISD::SIGN_EXTEND: case ISD::ZERO_EXTEND: - case ISD::ANY_EXTEND: - return PerformExtendCombine(N, DCI.DAG, Subtarget); + case ISD::ANY_EXTEND: return PerformExtendCombine(N, DCI.DAG, Subtarget); + case ISD::SELECT_CC: return PerformSELECT_CCCombine(N, DCI.DAG, Subtarget); } return SDValue(); } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=96572&r1=96571&r2=96572&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Thu Feb 18 00:05:53 2010 @@ -131,7 +131,11 @@ VREV16, // reverse elements within 16-bit halfwords VZIP, // zip (interleave) VUZP, // unzip (deinterleave) - VTRN // transpose + VTRN, // transpose + + // Floating-point max and min: + FMAX, + FMIN }; } Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=96572&r1=96571&r2=96572&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Thu Feb 18 00:05:53 2010 @@ -89,6 +89,11 @@ def NEONuzp : SDNode<"ARMISD::VUZP", SDTARMVSHUF2>; def NEONtrn : SDNode<"ARMISD::VTRN", SDTARMVSHUF2>; +def SDTARMFMAX : SDTypeProfile<1, 2, [SDTCisVT<0, f32>, SDTCisSameAs<0, 1>, + SDTCisSameAs<0, 2>]>; +def NEONfmax : SDNode<"ARMISD::FMAX", SDTARMFMAX>; +def NEONfmin : SDNode<"ARMISD::FMIN", SDTARMFMAX>; + //===----------------------------------------------------------------------===// // NEON operand definitions //===----------------------------------------------------------------------===// @@ -3023,6 +3028,20 @@ "vneg", "f32", "$dst, $src", "", []>; def : N2VSPat; +// Vector Maximum used for single-precision FP +let neverHasSideEffects = 1 in +def VMAXfd_sfp : N3V<0, 0, 0b00, 0b1111, 0, 0, (outs DPR_VFP2:$dst), + (ins DPR_VFP2:$src1, DPR_VFP2:$src2), IIC_VBIND, + "vmax", "f32", "$dst, $src1, $src2", "", []>; +def : N3VSPat; + +// Vector Minimum used for single-precision FP +let neverHasSideEffects = 1 in +def VMINfd_sfp : N3V<0, 0, 0b00, 0b1111, 0, 0, (outs DPR_VFP2:$dst), + (ins DPR_VFP2:$src1, DPR_VFP2:$src2), IIC_VBIND, + "vmin", "f32", "$dst, $src1, $src2", "", []>; +def : N3VSPat; + // Vector Convert between single-precision FP and integer let neverHasSideEffects = 1 in def VCVTf2sd_sfp : N2VS<0b11, 0b11, 0b10, 0b11, 0b01110, 0, "vcvt", "s32.f32", Added: llvm/trunk/test/CodeGen/ARM/neon_minmax.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/neon_minmax.ll?rev=96572&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/neon_minmax.ll (added) +++ llvm/trunk/test/CodeGen/ARM/neon_minmax.ll Thu Feb 18 00:05:53 2010 @@ -0,0 +1,65 @@ +; RUN: llc < %s -march=arm -mcpu=cortex-a8 | FileCheck %s + +define float @fmin_ole(float %x) nounwind { +;CHECK: fmin_ole: +;CHECK: vmin.f32 + %cond = fcmp ole float 1.0, %x + %min1 = select i1 %cond, float 1.0, float %x + ret float %min1 +} + +define float @fmin_ult(float %x) nounwind { +;CHECK: fmin_ult: +;CHECK: vmin.f32 + %cond = fcmp ult float %x, 1.0 + %min1 = select i1 %cond, float %x, float 1.0 + ret float %min1 +} + +define float @fmax_ogt(float %x) nounwind { +;CHECK: fmax_ogt: +;CHECK: vmax.f32 + %cond = fcmp ogt float 1.0, %x + %max1 = select i1 %cond, float 1.0, float %x + ret float %max1 +} + +define float @fmax_uge(float %x) nounwind { +;CHECK: fmax_uge: +;CHECK: vmax.f32 + %cond = fcmp uge float %x, 1.0 + %max1 = select i1 %cond, float %x, float 1.0 + ret float %max1 +} + +define float @fmax_olt_reverse(float %x) nounwind { +;CHECK: fmax_olt_reverse: +;CHECK: vmax.f32 + %cond = fcmp olt float %x, 1.0 + %max1 = select i1 %cond, float 1.0, float %x + ret float %max1 +} + +define float @fmax_ule_reverse(float %x) nounwind { +;CHECK: fmax_ule_reverse: +;CHECK: vmax.f32 + %cond = fcmp ult float 1.0, %x + %max1 = select i1 %cond, float %x, float 1.0 + ret float %max1 +} + +define float @fmin_oge_reverse(float %x) nounwind { +;CHECK: fmin_oge_reverse: +;CHECK: vmin.f32 + %cond = fcmp oge float %x, 1.0 + %min1 = select i1 %cond, float 1.0, float %x + ret float %min1 +} + +define float @fmin_ugt_reverse(float %x) nounwind { +;CHECK: fmin_ugt_reverse: +;CHECK: vmin.f32 + %cond = fcmp ugt float 1.0, %x + %min1 = select i1 %cond, float %x, float 1.0 + ret float %min1 +} From sabre at nondot.org Thu Feb 18 00:29:07 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Feb 2010 06:29:07 -0000 Subject: [llvm-commits] [llvm] r96573 - /llvm/trunk/test/CodeGen/X86/omit-label.ll Message-ID: <201002180629.o1I6T7pW025701@zion.cs.uiuc.edu> Author: lattner Date: Thu Feb 18 00:29:06 2010 New Revision: 96573 URL: http://llvm.org/viewvc/llvm-project?rev=96573&view=rev Log: remove empty file Removed: llvm/trunk/test/CodeGen/X86/omit-label.ll Removed: llvm/trunk/test/CodeGen/X86/omit-label.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/omit-label.ll?rev=96572&view=auto ============================================================================== (empty) From sabre at nondot.org Thu Feb 18 00:33:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Feb 2010 06:33:42 -0000 Subject: [llvm-commits] [llvm] r96574 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <201002180633.o1I6XgN8025856@zion.cs.uiuc.edu> Author: lattner Date: Thu Feb 18 00:33:42 2010 New Revision: 96574 URL: http://llvm.org/viewvc/llvm-project?rev=96574&view=rev Log: add a missing type cast. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=96574&r1=96573&r2=96574&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Feb 18 00:33:42 2010 @@ -3462,7 +3462,7 @@ (ins VR128:$src1, i128mem:$src2), !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), [(set VR128:$dst, - (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize; + (OpVT (OpNode VR128:$src1, (memop addr:$src2))))]>, OpSize; def rm_int : SS48I Author: lattner Date: Thu Feb 18 00:47:49 2010 New Revision: 96575 URL: http://llvm.org/viewvc/llvm-project?rev=96575&view=rev Log: start sketching out the structure of code for result emission generation. Nothing real here yet. Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h llvm/trunk/utils/TableGen/DAGISelEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=96575&r1=96574&r2=96575&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Thu Feb 18 00:47:49 2010 @@ -466,7 +466,8 @@ /// PatternToMatch - Used by CodeGenDAGPatterns to keep tab of patterns /// processed to produce isel. -struct PatternToMatch { +class PatternToMatch { +public: PatternToMatch(ListInit *preds, TreePatternNode *src, TreePatternNode *dst, const std::vector &dstregs, @@ -574,7 +575,7 @@ abort(); } - const DAGDefaultOperand &getDefaultOperand(Record *R) { + const DAGDefaultOperand &getDefaultOperand(Record *R) const { assert(DefaultOperands.count(R) &&"Isn't an analyzed default operand!"); return DefaultOperands.find(R)->second; } Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=96575&r1=96574&r2=96575&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Thu Feb 18 00:47:49 2010 @@ -1020,7 +1020,7 @@ } if (IsVariadic) emitCode("SmallVector Ops" + utostr(OpcNo) + ";"); - + // How many results is this pattern expected to produce? unsigned NumPatResults = 0; for (unsigned i = 0, e = Pattern->getExtTypes().size(); i != e; i++) { Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96575&r1=96574&r2=96575&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Thu Feb 18 00:47:49 2010 @@ -262,6 +262,9 @@ } void MatcherTableEmitter::EmitPredicateFunctions() { + // FIXME: Don't build off the DAGISelEmitter's predicates, emit them directly + // here into the case stmts. + // Emit pattern predicates. OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n"; OS << " switch (PredNo) {\n"; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96575&r1=96574&r2=96575&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Thu Feb 18 00:47:49 2010 @@ -48,16 +48,27 @@ } void EmitMatcherCode(); + void EmitResultCode(); MatcherNode *GetMatcher() const { return Matcher; } MatcherNode *GetCurPredicate() const { return CurPredicate; } private: void AddMatcherNode(MatcherNode *NewNode); void InferPossibleTypes(); + + // Matcher Generation. void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes); void EmitLeafMatchCode(const TreePatternNode *N); void EmitOperatorMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes); + + // Result Code Generation. + void EmitResultOperand(const TreePatternNode *N, + SmallVectorImpl &ResultOps); + void EmitResultLeafAsOperand(const TreePatternNode *N, + SmallVectorImpl &ResultOps); + void EmitResultInstructionAsOperand(const TreePatternNode *N, + SmallVectorImpl &ResultOps); }; } // end anon namespace. @@ -116,6 +127,9 @@ } +//===----------------------------------------------------------------------===// +// Pattern Match Generation +//===----------------------------------------------------------------------===// /// EmitLeafMatchCode - Generate matching code for leaf nodes. void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) { @@ -377,6 +391,103 @@ } +//===----------------------------------------------------------------------===// +// Node Result Generation +//===----------------------------------------------------------------------===// + +void MatcherGen::EmitResultLeafAsOperand(const TreePatternNode *N, + SmallVectorImpl &ResultOps) { + errs() << "unhandled leaf node: \n"; + N->dump(); +} + +void MatcherGen::EmitResultInstructionAsOperand(const TreePatternNode *N, + SmallVectorImpl &ResultOps) { + Record *Op = N->getOperator(); + const CodeGenTarget &CGT = CGP.getTargetInfo(); + CodeGenInstruction &II = CGT.getInstruction(Op->getName()); + const DAGInstruction &Inst = CGP.getInstruction(Op); + + // FIXME: Handle (set x, (foo)) + + if (II.isVariadic) // FIXME: Handle variadic instructions. + return AddMatcherNode(new EmitNodeMatcherNode(Pattern)); + + // FIXME: Handle OptInFlag, HasInFlag, HasOutFlag + // FIXME: Handle Chains. + unsigned NumResults = Inst.getNumResults(); + + + // Loop over all of the operands of the instruction pattern, emitting code + // to fill them all in. The node 'N' usually has number children equal to + // the number of input operands of the instruction. However, in cases + // where there are predicate operands for an instruction, we need to fill + // in the 'execute always' values. Match up the node operands to the + // instruction operands to do this. + SmallVector Ops; + for (unsigned ChildNo = 0, InstOpNo = NumResults, e = II.OperandList.size(); + InstOpNo != e; ++InstOpNo) { + + // Determine what to emit for this operand. + Record *OperandNode = II.OperandList[InstOpNo].Rec; + if ((OperandNode->isSubClassOf("PredicateOperand") || + OperandNode->isSubClassOf("OptionalDefOperand")) && + !CGP.getDefaultOperand(OperandNode).DefaultOps.empty()) { + // This is a predicate or optional def operand; emit the + // 'default ops' operands. + const DAGDefaultOperand &DefaultOp = + CGP.getDefaultOperand(II.OperandList[InstOpNo].Rec); + for (unsigned i = 0, e = DefaultOp.DefaultOps.size(); i != e; ++i) + EmitResultOperand(DefaultOp.DefaultOps[i], Ops); + continue; + } + + // Otherwise this is a normal operand or a predicate operand without + // 'execute always'; emit it. + EmitResultOperand(N->getChild(ChildNo), Ops); + ++ChildNo; + } + + // FIXME: Chain. + // FIXME: Flag + + + + return; +} + +void MatcherGen::EmitResultOperand(const TreePatternNode *N, + SmallVectorImpl &ResultOps) { + // This is something selected from the pattern we matched. + if (!N->getName().empty()) { + //errs() << "unhandled named node: \n"; + //N->dump(); + return; + } + + if (N->isLeaf()) + return EmitResultLeafAsOperand(N, ResultOps); + + Record *OpRec = N->getOperator(); + if (OpRec->isSubClassOf("Instruction")) + return EmitResultInstructionAsOperand(N, ResultOps); + if (OpRec->isSubClassOf("SDNodeXForm")) + // FIXME: implement. + return; + errs() << "Unknown result node to emit code for: " << *N << '\n'; + throw std::string("Unknown node in result pattern!"); +} + +void MatcherGen::EmitResultCode() { + // FIXME: Handle Ops. + // FIXME: Ops should be vector of "ResultValue> which is either an index into + // the results vector is is a temp result. + SmallVector Ops; + EmitResultOperand(Pattern.getDstPattern(), Ops); + //AddMatcherNode(new EmitNodeMatcherNode(Pattern)); +} + + MatcherNode *llvm::ConvertPatternToMatcher(const PatternToMatch &Pattern, const CodeGenDAGPatterns &CGP) { MatcherGen Gen(Pattern, CGP); @@ -385,16 +496,10 @@ Gen.EmitMatcherCode(); // If the match succeeds, then we generate Pattern. - EmitNodeMatcherNode *Result = new EmitNodeMatcherNode(Pattern); - - // Link it into the pattern. - if (MatcherNode *Pred = Gen.GetCurPredicate()) { - Pred->setNext(Result); - return Gen.GetMatcher(); - } + Gen.EmitResultCode(); // Unconditional match. - return Result; + return Gen.GetMatcher(); } From baldrick at free.fr Thu Feb 18 03:21:40 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 18 Feb 2010 10:21:40 +0100 Subject: [llvm-commits] [llvm] r96559 - in /llvm/trunk: Makefile Makefile.config.in Makefile.rules autoconf/configure.ac configure test/Makefile test/Unit/lit.cfg test/Unit/lit.site.cfg.in tools/llvm-shlib/ tools/llvm-shlib/Makefile unittests/Makefile.unittest In-Reply-To: <201002180236.o1I2a3D2015337@zion.cs.uiuc.edu> References: <201002180236.o1I2a3D2015337@zion.cs.uiuc.edu> Message-ID: <4B7D06A4.4050400@free.fr> Hi Jeffrey, > Add a shared library for LLVM, named libLLVM2.7svn.(so|dylib), how about libLLVM-2.7svn.so? On my linux system, all shared libraries with a version number containing a dot have a hyphen before the version. Ciao, Duncan. From baldrick at free.fr Thu Feb 18 03:59:27 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 18 Feb 2010 10:59:27 +0100 Subject: [llvm-commits] [llvm] r96526 - in /llvm/trunk/docs: AdvancedGetElementPtr.html index.html In-Reply-To: <201002172247.o1HMl6ZI003439@zion.cs.uiuc.edu> References: <201002172247.o1HMl6ZI003439@zion.cs.uiuc.edu> Message-ID: <4B7D0F7F.4020104@free.fr> Hi Dan, > +

    Also, GEP carries additional pointer aliasing rules. It's invalid to take a > + GEP from one object and address into a different separately allocated > + object. IR producers (front-ends) must follow this rule, and consumers > + (optimizers, specifically alias analysis) benefit from being able to rely > + on it.

    are you sure? I thought it was fine to have a GEP point outside an object (and possibly into another one) as long as you don't try to load from or store to that object. Also, the "no assumptions about where allocated objects are allocated" rule applies not just to GEP as far as I know. For example, suppose you have two consecutive "alloca i32", then do a ptrtoint on the first, add 4 bytes, and do an inttoptr. You cannot assume that the result points into the second alloca, yet there are no GEP's here. > +

    However, for of the underlying integer computation implied, there > + is no difference.

    for of -> for > +

    The second sense of being out of bounds is computing an address that's > + beyond of the actual underlying allocated object.

    beyond of -> beyond > +

    With the inbounds keyword, the result value of the GEP is > + undefined if the address is outside the actual underlying allocated > + object and not the address one-past-the-end.

    Are you sure, I thought only dereferencing such a pointer was the problem... > + Can I cast an object's address to integer and add it > + to null? > + > +
    > +

    You can compute an address that way, but you can't use that pointer to > + actually access the object if you do, unless the object is managed > + outside of LLVM.

    > + > +

    The underlying integer computation is sufficiently defined; null has a > + defined value -- zero -- and you can add whatever value you want to it.

    > + > +

    However, it's invalid to access (load from or store to) an LLVM-aware > + object with such a pointer. This includes GlobalVariables, Allocas, and > + objects pointed to by noalias pointers.

    Woah, that's an exciting rule! Has this always been the case? > +

    Instead, you should cast your pointer types and use arrays instead of > + vectors for addressing. Arrays have the same in-memory representation > + as vectors, so the addressing is interchangeable.

    Hah! See PR1784. Ciao, Duncan. From xerxes at zafena.se Thu Feb 18 04:53:45 2010 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Thu, 18 Feb 2010 11:53:45 +0100 Subject: [llvm-commits] [llvm] r96569 - in /llvm/trunk: Makefile Makefile.config.in Makefile.rules autoconf/configure.ac configure test/Makefile test/Unit/lit.cfg test/Unit/lit.site.cfg.in tools/llvm-shlib/ unittests/Makefile.unittest In-Reply-To: <201002180443.o1I4h31e021421@zion.cs.uiuc.edu> References: <201002180443.o1I4h31e021421@zion.cs.uiuc.edu> Message-ID: <4B7D1C39.7050001@zafena.se> Jeffrey Yasskin wrote: > Author: jyasskin > Date: Wed Feb 17 22:43:02 2010 > New Revision: 96569 > > URL: http://llvm.org/viewvc/llvm-project?rev=96569&view=rev > Log: > Roll back the shared library, r96559. It broke two darwins and arm, mysteriously. > > Hi The failure on arm: llvm[1]: Linking Debug Shared Library LLVM2.7svn.so /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicAdd(unsigned int volatile*, unsigned int)': /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:86: undefined reference to `__sync_add_and_fetch_4' /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicIncrement(unsigned int volatile*)': /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:60: undefined reference to `__sync_add_and_fetch_4' /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicDecrement(unsigned int volatile*)': /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:73: undefined reference to `__sync_sub_and_fetch_4' /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::CompareAndSwap(unsigned int volatile*, unsigned int, unsigned int)': /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:47: undefined reference to `__sync_val_compare_and_swap_4' collect2: ld returned 1 exit status I have seen something similar about one year ago when we tried to make libCompileDriver a shared library: http://markmail.org/message/cblcpfmsfab65vue The issue are that the symbol __sync_add_and_fetch_4 and friends do exists in libstdc++ but only in the static version. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133 Quoted Mikael Pettersson from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133#c8 " 1. g++ links shared libraries with -shared-libgcc, which apparently is important whenever exceptions are possible. 2. -shared-libgcc by definition excludes the static libgcc from the link command. 3. Since the __sync__ procedures are only present in the static libgcc, it follows that they cannot be used by -shared-libgcc objects like libstdc++.so. " A workaround might be to specify -lgcc to force linking in the static libstdc++ that contains the missing symbols. Good news are that it looks like this bug should have been resolved in gcc trunk. I will do some tests with r96559 applied on arm to see if this can be workaround by a: make the linking work by specifying -lgcc during linking. or b: upgrade gcc and libstdc++ on the buildbot to a newer version. Cheers Xerxes From benny.kra at googlemail.com Thu Feb 18 06:57:06 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 18 Feb 2010 12:57:06 -0000 Subject: [llvm-commits] [llvm] r96576 - /llvm/trunk/tools/opt/opt.cpp Message-ID: <201002181257.o1ICv6lW025214@zion.cs.uiuc.edu> Author: d0k Date: Thu Feb 18 06:57:05 2010 New Revision: 96576 URL: http://llvm.org/viewvc/llvm-project?rev=96576&view=rev Log: Avoid a dangling pointer dereference, PassManager::add can delete the Pass. Modified: llvm/trunk/tools/opt/opt.cpp Modified: llvm/trunk/tools/opt/opt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=96576&r1=96575&r2=96576&view=diff ============================================================================== --- llvm/trunk/tools/opt/opt.cpp (original) +++ llvm/trunk/tools/opt/opt.cpp Thu Feb 18 06:57:05 2010 @@ -475,10 +475,11 @@ errs() << argv[0] << ": cannot create pass: " << PassInf->getPassName() << "\n"; if (P) { + PassKind Kind = P->getPassKind(); addPass(Passes, P); if (AnalyzeOnly) { - switch (P->getPassKind()) { + switch (Kind) { case PT_BasicBlock: Passes.add(new BasicBlockPassPrinter(PassInf)); break; From baldrick at free.fr Thu Feb 18 08:08:14 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 18 Feb 2010 14:08:14 -0000 Subject: [llvm-commits] [llvm] r96578 - in /llvm/trunk: docs/ docs/CommandGuide/ include/llvm/CompilerDriver/ include/llvm/Support/ lib/Support/ Message-ID: <201002181408.o1IE8EBo028152@zion.cs.uiuc.edu> Author: baldrick Date: Thu Feb 18 08:08:13 2010 New Revision: 96578 URL: http://llvm.org/viewvc/llvm-project?rev=96578&view=rev Log: Refer to -help instead of --help since this is what tools themselves say. Also, have tools output -help-hidden rather than refer to --help-hidden, for consistency, and likewise adjust documentation. This doesn't change every mention of --help, only those which seemed clearly safe. Modified: llvm/trunk/docs/CommandGuide/FileCheck.pod llvm/trunk/docs/CommandGuide/bugpoint.pod llvm/trunk/docs/CommandGuide/index.html llvm/trunk/docs/CommandGuide/llc.pod llvm/trunk/docs/CommandGuide/lli.pod llvm/trunk/docs/CommandGuide/llvm-as.pod llvm/trunk/docs/CommandGuide/llvm-bcanalyzer.pod llvm/trunk/docs/CommandGuide/llvm-config.pod llvm/trunk/docs/CommandGuide/llvm-dis.pod llvm/trunk/docs/CommandGuide/llvm-extract.pod llvm/trunk/docs/CommandGuide/llvm-link.pod llvm/trunk/docs/CommandGuide/llvm-nm.pod llvm/trunk/docs/CommandGuide/llvm-prof.pod llvm/trunk/docs/CommandGuide/llvm-ranlib.pod llvm/trunk/docs/CommandGuide/llvmc.pod llvm/trunk/docs/CommandGuide/tblgen.pod llvm/trunk/docs/CommandLine.html llvm/trunk/docs/CompilerDriver.html llvm/trunk/docs/GettingStarted.html llvm/trunk/docs/WritingAnLLVMPass.html llvm/trunk/include/llvm/CompilerDriver/Main.inc llvm/trunk/include/llvm/Support/CommandLine.h llvm/trunk/lib/Support/CommandLine.cpp Modified: llvm/trunk/docs/CommandGuide/FileCheck.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/FileCheck.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/FileCheck.pod (original) +++ llvm/trunk/docs/CommandGuide/FileCheck.pod Thu Feb 18 08:08:13 2010 @@ -25,7 +25,7 @@ =over -=item B<--help> +=item B<-help> Print a summary of command line options. Modified: llvm/trunk/docs/CommandGuide/bugpoint.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/bugpoint.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/bugpoint.pod (original) +++ llvm/trunk/docs/CommandGuide/bugpoint.pod Thu Feb 18 08:08:13 2010 @@ -85,7 +85,7 @@ Continually randomize the specified passes and run them on the test program until a bug is found or the user kills B. -=item B<--help> +=item B<-help> Print a summary of command line options. @@ -99,9 +99,9 @@ Load the dynamic object F into B itself. This object should register new optimization passes. Once loaded, the object will add new command line options to enable various optimizations. To see the new complete list of -optimizations, use the B<--help> and B<--load> options together; for example: +optimizations, use the B<-help> and B<--load> options together; for example: - bugpoint --load myNewPass.so --help + bugpoint --load myNewPass.so -help =item B<--mlimit> F Modified: llvm/trunk/docs/CommandGuide/index.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/index.html?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/index.html (original) +++ llvm/trunk/docs/CommandGuide/index.html Thu Feb 18 08:08:13 2010 @@ -17,7 +17,7 @@ for all of the LLVM tools. These pages describe how to use the LLVM commands and what their options are. Note that these pages do not describe all of the options available for all tools. To get a complete listing, pass the ---help (general options) or --help-hidden (general+debugging +-help (general options) or -help-hidden (general+debugging options) arguments to the tool you are interested in.

    Modified: llvm/trunk/docs/CommandGuide/llc.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llc.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llc.pod (original) +++ llvm/trunk/docs/CommandGuide/llc.pod Thu Feb 18 08:08:13 2010 @@ -38,7 +38,7 @@ =over -=item B<--help> +=item B<-help> Print a summary of command line options. @@ -56,7 +56,7 @@ =item B<-march>=I Specify the architecture for which to generate assembly, overriding the target -encoded in the input file. See the output of B for a list of +encoded in the input file. See the output of B for a list of valid architectures. By default this is inferred from the target triple or autodetected to the current architecture. Modified: llvm/trunk/docs/CommandGuide/lli.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/lli.pod (original) +++ llvm/trunk/docs/CommandGuide/lli.pod Thu Feb 18 08:08:13 2010 @@ -73,7 +73,7 @@ =item B<-march>=I Specify the architecture for which to generate assembly, overriding the target -encoded in the bitcode file. See the output of B for a list of +encoded in the bitcode file. See the output of B for a list of valid architectures. By default this is inferred from the target triple or autodetected to the current architecture. Modified: llvm/trunk/docs/CommandGuide/llvm-as.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-as.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-as.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-as.pod Thu Feb 18 08:08:13 2010 @@ -50,7 +50,7 @@ write raw bitcode output if the output stream is a terminal. With this option, B will write raw bitcode regardless of the output device. -=item B<--help> +=item B<-help> Print a summary of command line options. Modified: llvm/trunk/docs/CommandGuide/llvm-bcanalyzer.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-bcanalyzer.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-bcanalyzer.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-bcanalyzer.pod Thu Feb 18 08:08:13 2010 @@ -43,7 +43,7 @@ bitcode. This ensures that the statistics generated are based on a consistent module. -=item B<--help> +=item B<-help> Print a summary of command line options. Modified: llvm/trunk/docs/CommandGuide/llvm-config.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-config.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-config.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-config.pod Thu Feb 18 08:08:13 2010 @@ -30,7 +30,7 @@ Print the version number of LLVM. -=item B<--help> +=item B<-help> Print a summary of B arguments. Modified: llvm/trunk/docs/CommandGuide/llvm-dis.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-dis.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-dis.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-dis.pod Thu Feb 18 08:08:13 2010 @@ -33,7 +33,7 @@ write raw bitcode output if the output stream is a terminal. With this option, B will write raw bitcode regardless of the output device. -=item B<--help> +=item B<-help> Print a summary of command line options. Modified: llvm/trunk/docs/CommandGuide/llvm-extract.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-extract.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-extract.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-extract.pod Thu Feb 18 08:08:13 2010 @@ -42,7 +42,7 @@ Extract the global variable named I from the LLVM bitcode. May be specified multiple times to extract multiple global variables at once. -=item B<--help> +=item B<-help> Print a summary of command line options. Modified: llvm/trunk/docs/CommandGuide/llvm-link.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-link.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-link.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-link.pod Thu Feb 18 08:08:13 2010 @@ -51,7 +51,7 @@ If specified, B prints a human-readable version of the output bitcode file to standard error. -=item B<--help> +=item B<-help> Print a summary of command line options. Modified: llvm/trunk/docs/CommandGuide/llvm-nm.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-nm.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-nm.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-nm.pod Thu Feb 18 08:08:13 2010 @@ -77,7 +77,7 @@ Use BSD output format. Alias for B<--format=bsd>. -=item B<--help> +=item B<-help> Print a summary of command-line options and their meanings. Modified: llvm/trunk/docs/CommandGuide/llvm-prof.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-prof.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-prof.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-prof.pod Thu Feb 18 08:08:13 2010 @@ -18,7 +18,7 @@ This program is often used in conjunction with the F script. This script automatically instruments a program, runs it with the JIT, then runs B to format a report. To get more information about -F, execute it with the B<--help> option. +F, execute it with the B<-help> option. =head1 OPTIONS Modified: llvm/trunk/docs/CommandGuide/llvm-ranlib.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvm-ranlib.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvm-ranlib.pod (original) +++ llvm/trunk/docs/CommandGuide/llvm-ranlib.pod Thu Feb 18 08:08:13 2010 @@ -6,7 +6,7 @@ =head1 SYNOPSIS -B [--version] [--help] +B [--version] [-help] =head1 DESCRIPTION @@ -30,7 +30,7 @@ Print the version of B and exit without building a symbol table. -=item F<--help> +=item F<-help> Print usage help for B and exit without building a symbol table. Modified: llvm/trunk/docs/CommandGuide/llvmc.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvmc.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvmc.pod (original) +++ llvm/trunk/docs/CommandGuide/llvmc.pod Thu Feb 18 08:08:13 2010 @@ -77,11 +77,11 @@ unless I<--save-temps> is specified. If I<--save-temps=obj> is also specified, I<--temp-dir> is given the precedence. -=item B<--help> +=item B<-help> Print a summary of command-line options and exit. -=item B<--help-hidden> +=item B<-help-hidden> Print a summary of command-line options and exit. Print help even for options intended for developers. Modified: llvm/trunk/docs/CommandGuide/tblgen.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/tblgen.pod?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/tblgen.pod (original) +++ llvm/trunk/docs/CommandGuide/tblgen.pod Thu Feb 18 08:08:13 2010 @@ -26,7 +26,7 @@ =over -=item B<--help> +=item B<-help> Print a summary of command line options. Modified: llvm/trunk/docs/CommandLine.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandLine.html?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/CommandLine.html (original) +++ llvm/trunk/docs/CommandLine.html Thu Feb 18 08:08:13 2010 @@ -44,7 +44,7 @@
  • Option Modifiers @@ -325,7 +325,7 @@
  • Possible option properties:

      -
    • help - help string associated with this option. Used for --help +
    • help - help string associated with this option. Used for -help output.
    • required - this option must be specified exactly once (or, in case of the list options without the multi_val property, at least @@ -338,7 +338,7 @@ for list options in conjunction with multi_val. Incompatible with required and one_or_more.
    • hidden - the description of this option will not appear in -the --help output (but will appear in the --help-hidden +the -help output (but will appear in the -help-hidden output).
    • really_hidden - the option will not be mentioned in any help output.
    • @@ -748,7 +748,7 @@ Mikhail Glushenkov
      LLVM Compiler Infrastructure
      -Last modified: $Date: 2008-12-11 11:34:48 -0600 (Thu, 11 Dec 2008) $ +Last modified: $Date$ Modified: llvm/trunk/docs/GettingStarted.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/GettingStarted.html (original) +++ llvm/trunk/docs/GettingStarted.html Thu Feb 18 08:08:13 2010 @@ -1369,7 +1369,7 @@

      The tools directory contains the executables built out of the libraries above, which form the main part of the user interface. You can -always get help for a tool by typing tool_name --help. The +always get help for a tool by typing tool_name -help. The following is a brief introduction to the most important tools. More detailed information is in the Command Guide.

      @@ -1440,7 +1440,7 @@
      opt
      opt reads LLVM bitcode, applies a series of LLVM to LLVM transformations (which are specified on the command line), and then outputs - the resultant bitcode. The 'opt --help' command is a good way to + the resultant bitcode. The 'opt -help' command is a good way to get a list of the program transformations available in LLVM.
      opt can also be used to run a specific analysis on an input LLVM bitcode file and print out the results. It is primarily useful for Modified: llvm/trunk/docs/WritingAnLLVMPass.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/WritingAnLLVMPass.html?rev=96578&r1=96577&r2=96578&view=diff ============================================================================== --- llvm/trunk/docs/WritingAnLLVMPass.html (original) +++ llvm/trunk/docs/WritingAnLLVMPass.html Thu Feb 18 08:08:13 2010 @@ -377,10 +377,10 @@ /dev/null).

      To see what happened to the other string you registered, try running -opt with the --help option:

      +opt with the -help option:

      -$ opt -load ../../../Debug/lib/Hello.so --help
      +$ opt -load ../../../Debug/lib/Hello.so -help
       OVERVIEW: llvm .bc -> .bc modular optimizer
       
       USAGE: opt [options] <input bitcode>
      @@ -970,7 +970,7 @@
       parameters.  The first parameter is the name of the pass that is to be used on
       the command line to specify that the pass should be added to a program (for
       example, with opt or bugpoint).  The second argument is the
      -name of the pass, which is to be used for the --help output of
      +name of the pass, which is to be used for the -help output of
       programs, as
       well as for debug output generated by the --debug-pass option.

      @@ -1410,7 +1410,7 @@ options that is useful for debugging pass execution, seeing how things work, and diagnosing when you should be preserving more analyses than you currently are (To get information about all of the variants of the --debug-pass -option, just type 'opt --help-hidden').

      +option, just type 'opt -help-hidden').

      By using the --debug-pass=Structure option, for example, we can see how our Hello World pass interacts with other passes. @@ -1625,10 +1625,10 @@

      Note the two spaces prior to the help string produces a tidy result on the ---help query.

      +-help query.

      -$ llc --help
      +$ llc -help
         ...
         -regalloc                    - Register allocator to use: (default = linearscan)
           =linearscan                -   linear scan register allocator
      
      Modified: llvm/trunk/include/llvm/CompilerDriver/Main.inc
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Main.inc?rev=96578&r1=96577&r2=96578&view=diff
      
      ==============================================================================
      --- llvm/trunk/include/llvm/CompilerDriver/Main.inc (original)
      +++ llvm/trunk/include/llvm/CompilerDriver/Main.inc Thu Feb 18 08:08:13 2010
      @@ -10,7 +10,7 @@
       //  This tool provides a single point of access to the LLVM
       //  compilation tools.  It has many options. To discover the options
       //  supported please refer to the tools' manual page or run the tool
      -//  with the --help option.
      +//  with the -help option.
       //
       //  This file provides the default entry point for the driver executable.
       //
      
      Modified: llvm/trunk/include/llvm/Support/CommandLine.h
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=96578&r1=96577&r2=96578&view=diff
      
      ==============================================================================
      --- llvm/trunk/include/llvm/Support/CommandLine.h (original)
      +++ llvm/trunk/include/llvm/Support/CommandLine.h Thu Feb 18 08:08:13 2010
      @@ -93,9 +93,9 @@
       };
       
       enum OptionHidden {            // Control whether -help shows this option
      -  NotHidden       = 0x20,      // Option included in --help & --help-hidden
      -  Hidden          = 0x40,      // -help doesn't, but --help-hidden does
      -  ReallyHidden    = 0x60,      // Neither --help nor --help-hidden show this arg
      +  NotHidden       = 0x20,      // Option included in -help & -help-hidden
      +  Hidden          = 0x40,      // -help doesn't, but -help-hidden does
      +  ReallyHidden    = 0x60,      // Neither -help nor -help-hidden show this arg
         HiddenMask      = 0x60
       };
       
      @@ -159,7 +159,7 @@
         Option *NextRegistered; // Singly linked list of registered options.
       public:
         const char *ArgStr;     // The argument string itself (ex: "help", "o")
      -  const char *HelpStr;    // The descriptive text message for --help
      +  const char *HelpStr;    // The descriptive text message for -help
         const char *ValueStr;   // String describing what the value of this option is
       
         inline enum NumOccurrencesFlag getNumOccurrencesFlag() const {
      @@ -251,14 +251,14 @@
       // command line option parsers...
       //
       
      -// desc - Modifier to set the description shown in the --help output...
      +// desc - Modifier to set the description shown in the -help output...
       struct desc {
         const char *Desc;
         desc(const char *Str) : Desc(Str) {}
         void apply(Option &O) const { O.setDescription(Desc); }
       };
       
      -// value_desc - Modifier to set the value description shown in the --help
      +// value_desc - Modifier to set the value description shown in the -help
       // output...
       struct value_desc {
         const char *Desc;
      @@ -437,7 +437,7 @@
       // Default parser implementation - This implementation depends on having a
       // mapping of recognized options to values of some sort.  In addition to this,
       // each entry in the mapping also tracks a help message that is printed with the
      -// command line option for --help.  Because this is a simple mapping parser, the
      +// command line option for -help.  Because this is a simple mapping parser, the
       // data type can be any unsupported type.
       //
       template 
      @@ -1373,7 +1373,7 @@
       
       void PrintVersionMessage();
       // This function just prints the help message, exactly the same way as if the
      -// --help option had been given on the command line.
      +// -help option had been given on the command line.
       // NOTE: THIS FUNCTION TERMINATES THE PROGRAM!
       void PrintHelpMessage();
       
      
      Modified: llvm/trunk/lib/Support/CommandLine.cpp
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=96578&r1=96577&r2=96578&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/Support/CommandLine.cpp (original)
      +++ llvm/trunk/lib/Support/CommandLine.cpp Thu Feb 18 08:08:13 2010
      @@ -650,7 +650,7 @@
           if (Handler == 0) {
             if (SinkOpts.empty()) {
               errs() << ProgramName << ": Unknown command line argument '"
      -             << argv[i] << "'.  Try: '" << argv[0] << " --help'\n";
      +             << argv[i] << "'.  Try: '" << argv[0] << " -help'\n";
               ErrorParsing = true;
             } else {
               for (SmallVectorImpl::iterator I = SinkOpts.begin(),
      @@ -673,7 +673,7 @@
           errs() << ProgramName
                << ": Not enough positional command line arguments specified!\n"
                << "Must specify at least " << NumPositionalRequired
      -         << " positional arguments: See: " << argv[0] << " --help\n";
      +         << " positional arguments: See: " << argv[0] << " -help\n";
       
           ErrorParsing = true;
         } else if (!HasUnlimitedPositionals
      @@ -681,7 +681,7 @@
           errs() << ProgramName
                << ": Too many positional arguments specified!\n"
                << "Can specify at most " << PositionalOpts.size()
      -         << " positional arguments: See: " << argv[0] << " --help\n";
      +         << " positional arguments: See: " << argv[0] << " -help\n";
           ErrorParsing = true;
       
         } else if (ConsumeAfterOpt == 0) {
      @@ -1029,7 +1029,7 @@
       
       
       //===----------------------------------------------------------------------===//
      -// --help and --help-hidden option implementation
      +// -help and -help-hidden option implementation
       //
       
       static int OptNameCompare(const void *LHS, const void *RHS) {
      @@ -1134,7 +1134,7 @@
       static HelpPrinter HiddenPrinter(true);
       
       static cl::opt >
      -HOp("help", cl::desc("Display available options (--help-hidden for more)"),
      +HOp("help", cl::desc("Display available options (-help-hidden for more)"),
           cl::location(NormalPrinter), cl::ValueDisallowed);
       
       static cl::opt >
      @@ -1222,8 +1222,8 @@
         // NormalPrinter variable is a HelpPrinter and the help gets printed when
         // its operator= is invoked. That's because the "normal" usages of the
         // help printer is to be assigned true/false depending on whether the
      -  // --help option was given or not. Since we're circumventing that we have
      -  // to make it look like --help was given, so we assign true.
      +  // -help option was given or not. Since we're circumventing that we have
      +  // to make it look like -help was given, so we assign true.
         NormalPrinter = true;
       }
       
      
      
      
      
      From baldrick at free.fr  Thu Feb 18 08:10:41 2010
      From: baldrick at free.fr (Duncan Sands)
      Date: Thu, 18 Feb 2010 14:10:41 -0000
      Subject: [llvm-commits] [llvm] r96579 -
      	/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp
      Message-ID: <201002181410.o1IEAglZ028282@zion.cs.uiuc.edu>
      
      Author: baldrick
      Date: Thu Feb 18 08:10:41 2010
      New Revision: 96579
      
      URL: http://llvm.org/viewvc/llvm-project?rev=96579&view=rev
      Log:
      Remove terminating dot in description.  Inconsistency pointed
      out by Russell Wallace.
      
      Modified:
          llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp
      
      Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=96579&r1=96578&r2=96579&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original)
      +++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Thu Feb 18 08:10:41 2010
      @@ -57,7 +57,7 @@
       using namespace llvm;
       
       static RegisterRegAlloc
      -registerPBQPRepAlloc("pbqp", "PBQP register allocator.",
      +registerPBQPRepAlloc("pbqp", "PBQP register allocator",
                              llvm::createPBQPRegisterAllocator);
       
       static cl::opt
      
      
      
      
      From baldrick at free.fr  Thu Feb 18 08:37:52 2010
      From: baldrick at free.fr (Duncan Sands)
      Date: Thu, 18 Feb 2010 14:37:52 -0000
      Subject: [llvm-commits] [llvm] r96580 - in /llvm/trunk:
       docs/CommandGuide/lli.pod docs/WritingAnLLVMPass.html
       lib/CodeGen/Passes.cpp lib/CodeGen/VirtRegRewriter.cpp
       tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
      Message-ID: <201002181437.o1IEbq59029563@zion.cs.uiuc.edu>
      
      Author: baldrick
      Date: Thu Feb 18 08:37:52 2010
      New Revision: 96580
      
      URL: http://llvm.org/viewvc/llvm-project?rev=96580&view=rev
      Log:
      Uniformize the way these options are printed.  Requested by
      Russell Wallace.
      
      Modified:
          llvm/trunk/docs/CommandGuide/lli.pod
          llvm/trunk/docs/WritingAnLLVMPass.html
          llvm/trunk/lib/CodeGen/Passes.cpp
          llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
          llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
      
      Modified: llvm/trunk/docs/CommandGuide/lli.pod
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/lli.pod?rev=96580&r1=96579&r2=96580&view=diff
      
      ==============================================================================
      --- llvm/trunk/docs/CommandGuide/lli.pod (original)
      +++ llvm/trunk/docs/CommandGuide/lli.pod Thu Feb 18 08:37:52 2010
      @@ -170,7 +170,7 @@
       
       =item B<-regalloc>=I
       
      -Register allocator to use: (default = linearscan)
      +Register allocator to use (default=linearscan)
       
           =bigblock: Big-block register allocator 
           =linearscan: linear scan register allocator =local -   local register allocator 
      @@ -186,7 +186,7 @@
       
       =item B<-spiller>
       
      -Spiller to use: (default: local) 
      +Spiller to use (default=local) 
       
           =simple: simple spiller 
           =local: local spiller 
      
      Modified: llvm/trunk/docs/WritingAnLLVMPass.html
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/WritingAnLLVMPass.html?rev=96580&r1=96579&r2=96580&view=diff
      
      ==============================================================================
      --- llvm/trunk/docs/WritingAnLLVMPass.html (original)
      +++ llvm/trunk/docs/WritingAnLLVMPass.html Thu Feb 18 08:37:52 2010
      @@ -1630,7 +1630,7 @@
       
       $ llc -help
         ...
      -  -regalloc                    - Register allocator to use: (default = linearscan)
      +  -regalloc                    - Register allocator to use (default=linearscan)
           =linearscan                -   linear scan register allocator
           =local                     -   local register allocator
           =simple                    -   simple register allocator
      
      Modified: llvm/trunk/lib/CodeGen/Passes.cpp
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=96580&r1=96579&r2=96580&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/CodeGen/Passes.cpp (original)
      +++ llvm/trunk/lib/CodeGen/Passes.cpp Thu Feb 18 08:37:52 2010
      @@ -34,7 +34,7 @@
                      RegisterPassParser >
       RegAlloc("regalloc",
                cl::init(&createLinearScanRegisterAllocator),
      -         cl::desc("Register allocator to use: (default = linearscan)")); 
      +         cl::desc("Register allocator to use (default=linearscan)")); 
       
       
       //===---------------------------------------------------------------------===//
      
      Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=96580&r1=96579&r2=96580&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original)
      +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Thu Feb 18 08:37:52 2010
      @@ -46,7 +46,7 @@
       
       static cl::opt
       RewriterOpt("rewriter",
      -            cl::desc("Rewriter to use: (default: local)"),
      +            cl::desc("Rewriter to use (default=local)"),
                   cl::Prefix,
                   cl::values(clEnumVal(local,   "local rewriter"),
                              clEnumVal(trivial, "trivial rewriter"),
      
      Modified: llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td?rev=96580&r1=96579&r2=96580&view=diff
      
      ==============================================================================
      --- llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td (original)
      +++ llvm/trunk/tools/llvmc/example/mcc16/plugins/PIC16Base/PIC16Base.td Thu Feb 18 08:37:52 2010
      @@ -56,7 +56,7 @@
       // (parameter_option "pre-RA-sched",
       //    (help "Example of an option that is passed to llc")),
        (parameter_option "regalloc",
      -    (help "Register allocator to use.(possible values: simple, linearscan, pbqp, local. default = linearscan)")),
      +    (help "Register allocator to use (possible values: simple, linearscan, pbqp, local; default=linearscan)")),
        (prefix_list_option "Wa,", (comma_separated),
           (help "Pass options to assembler (Run 'gpasm -help' for assembler options)")),
        (prefix_list_option "Wl,", (comma_separated),
      
      
      
      
      From jyasskin at google.com  Thu Feb 18 10:46:57 2010
      From: jyasskin at google.com (Jeffrey Yasskin)
      Date: Thu, 18 Feb 2010 08:46:57 -0800
      Subject: [llvm-commits] [llvm] r96569 - in /llvm/trunk: Makefile
      	Makefile.config.in Makefile.rules autoconf/configure.ac
      	configure test/Makefile test/Unit/lit.cfg
      	test/Unit/lit.site.cfg.in tools/llvm-shlib/
      	unittests/Makefile.unittest
      In-Reply-To: <4B7D1C39.7050001@zafena.se>
      References: <201002180443.o1I4h31e021421@zion.cs.uiuc.edu>
      	<4B7D1C39.7050001@zafena.se>
      Message-ID: <5d44f72f1002180846i179a9eb0m610f3067b6157e54@mail.gmail.com>
      
      On Thu, Feb 18, 2010 at 2:53 AM, Xerxes R?nby  wrote:
      > Jeffrey Yasskin wrote:
      >> Author: jyasskin
      >> Date: Wed Feb 17 22:43:02 2010
      >> New Revision: 96569
      >>
      >> URL: http://llvm.org/viewvc/llvm-project?rev=96569&view=rev
      >> Log:
      >> Roll back the shared library, r96559. ?It broke two darwins and arm, mysteriously.
      >>
      >>
      > Hi
      > The failure on arm:
      >
      > llvm[1]: Linking Debug Shared Library LLVM2.7svn.so
      > /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicAdd(unsigned int volatile*, unsigned int)':
      > /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:86: undefined reference to `__sync_add_and_fetch_4'
      > /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicIncrement(unsigned int volatile*)':
      > /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:60: undefined reference to `__sync_add_and_fetch_4'
      > /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicDecrement(unsigned int volatile*)':
      > /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:73: undefined reference to `__sync_sub_and_fetch_4'
      > /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::CompareAndSwap(unsigned int volatile*, unsigned int, unsigned int)':
      > /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:47: undefined reference to `__sync_val_compare_and_swap_4'
      > collect2: ld returned 1 exit status
      >
      > I have seen something similar about one year ago when we tried to make
      > libCompileDriver a shared library:
      > http://markmail.org/message/cblcpfmsfab65vue
      >
      > The issue are that the symbol __sync_add_and_fetch_4 and friends do
      > exists in libstdc++ but only in the static version.
      >
      > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133
      > Quoted Mikael Pettersson from
      > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133#c8
      > "
      > 1. g++ links shared libraries with -shared-libgcc, which apparently is
      > important whenever exceptions are possible.
      > 2. -shared-libgcc by definition excludes the static libgcc from the link
      > command.
      > 3. Since the __sync__ procedures are only present in the static libgcc,
      > it follows that they cannot be used by -shared-libgcc objects like
      > libstdc++.so.
      > "
      >
      > A workaround might be to specify -lgcc to force linking in the static
      > libstdc++ that contains the missing symbols.
      >
      > Good news are that it looks like this bug should have been resolved in
      > gcc trunk.
      > I will do some tests with r96559 applied on arm to see if this can be
      > workaround by
      >
      > a: make the linking work by specifying -lgcc during linking.
      > or
      > b: upgrade gcc and libstdc++ on the buildbot to a newer version.
      >
      > Cheers
      > Xerxes
      
      Thanks for the explanation of the problem! To work around it, I'm
      going to remove -Wl,--no-undefined from the ARM build. I think the
      shared library should still find the __sync primitives defined in the
      main executable, and we'll get assurance that the library is complete
      from builds on non-ARM platforms.
      
      
      
      From sanjiv.gupta at microchip.com  Thu Feb 18 11:32:25 2010
      From: sanjiv.gupta at microchip.com (Sanjiv Gupta)
      Date: Thu, 18 Feb 2010 17:32:25 -0000
      Subject: [llvm-commits] [llvm] r96589 - in
       /llvm/trunk/lib/Target/PIC16/PIC16Passes: PIC16Cloner.cpp PIC16Cloner.h
      Message-ID: <201002181732.o1IHWPHd005265@zion.cs.uiuc.edu>
      
      Author: sgupta
      Date: Thu Feb 18 11:32:25 2010
      New Revision: 96589
      
      URL: http://llvm.org/viewvc/llvm-project?rev=96589&view=rev
      Log:
      Re-factoring.
      
      Modified:
          llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
          llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
      
      Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp?rev=96589&r1=96588&r2=96589&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp (original)
      +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp Thu Feb 18 11:32:25 2010
      @@ -68,56 +68,84 @@
       //
       bool PIC16Cloner::runOnModule(Module &M) {
          CallGraph &CG = getAnalysis();
      -   // Initially record that no interrupt has been found
      -   foundISR = false;
       
      -   // First mark the MainLine. 
      +   // Search for the "main" and "ISR" functions.
      +   CallGraphNode *mainCGN = NULL, *isrCGN = NULL;
          for (CallGraph::iterator it = CG.begin() ; it != CG.end(); it++)
          {
      -     // External calling node doesn't have any function associated 
      -     // with it
      -     if (!it->first)
      +     // External calling node doesn't have any function associated with it.
      +     if (! it->first)
              continue;
            
            if (it->first->getName().str() == "main") {
      -       // See if the main itself is interrupt function then report an error.
      -       if (PAN::isISR(it->first->getSection()))
      -          reportError("Function 'main' can't be interrupt function");
      -       else  { 
      -         // Function main itself is MainLine function.
      -         it->second->getFunction()->setSection("ML");
      -         // mark the hierarchy 
      -         markCallGraph(it->second, "ML");
      -         // MainLine has been marked now break ; don't search any further.
      -         break;
      -       }
      -     } 
      +       mainCGN = it->second;
      +     }
      +
      +     if (PAN::isISR(it->first->getSection())) {
      +       isrCGN = it->second;
      +     }
      + 
      +     // Don't search further if we've found both.
      +     if (mainCGN && isrCGN)
      +       break;
      +   }
      +       
      +   // Time for some diagnostics.
      +   // See if the main itself is interrupt function then report an error.
      +   if (PAN::isISR(mainCGN->getFunction()->getSection())) {
      +     reportError("Function 'main' can't be interrupt function");
          }
       
      -   // When the MainLine has been marked only then mark the InterruptLine.
      -   for (CallGraph::iterator it = CG.begin() ; it != CG.end(); it++)
      -   {
      -     // External calling node doesn't have any function associated 
      -     // with it
      -     if (!it->first)
      -       continue;
      +    
      +   // Mark all reachable functions from main as ML.
      +   markCallGraph(mainCGN, "ML");
       
      -     if (PAN::isISR(it->first->getSection())) {
      +   // And then all the functions reachable from ISR will be cloned.
      +   cloneSharedFunctions(isrCGN);
      +
      +   return true;
      +}
       
      -       if (foundISR)
      -         reportError("More than one interrupt functions defined in the module");
      +// Mark all reachable functions from the given node, with the given mark.
      +//
      +void PIC16Cloner::markCallGraph(CallGraphNode *CGN, string StringMark) {
      +  // Mark the top node first.
      +  Function *thisF = CGN->getFunction();
       
      -       foundISR = true;
      -       
      -       markCallGraph(it->second, "IL");
      -       // InterruptLine handled now break; don't search any further.
      -       break;
      +  thisF->setSection(StringMark);
      +
      +  // Mark all the called functions
      +  for(CallGraphNode::iterator cgn_it = CGN->begin();
      +              cgn_it != CGN->end(); ++cgn_it) {
      +     Function *CalledF = cgn_it->second->getFunction();
      +
      +     // If calling an external function then CallGraphNode
      +     // will not be associated with any function.
      +     if (! CalledF)
      +       continue;
      +  
      +     // Issue diagnostic if interrupt function is being called.
      +     if (PAN::isISR(CalledF->getSection())) {
      +       vector Values;
      +       Values.push_back(CalledF->getName().str());
      +       reportError("Interrupt function (%0) can't be called", Values); 
      +     }
      +
      +     // Has already been mark 
      +     if (CalledF->getSection().find(StringMark) != string::npos) {
      +       // Should we do anything here?
      +     } else {
      +       // Mark now
      +       CalledF->setSection(StringMark);
            }
      -   } 
      -   
      -  return true;
      +
      +     // Before going any further mark all the called function by current
      +     // function.
      +     markCallGraph(cgn_it->second ,StringMark);
      +  } // end of loop of all called functions.
       }
       
      +
       // For PIC16, automatic variables of a function are emitted as globals.
       // Clone the auto variables of a function  and put them in ValueMap, 
       // this ValueMap will be used while
      @@ -158,16 +186,12 @@
       }
       
       
      -// Mark all reachable functions from the given node, with the given mark.
      +// Clone all functions that are reachable from ISR and are already 
      +// marked as ML.
       //
      -void PIC16Cloner::markCallGraph(CallGraphNode *CGN, string StringMark) {
      -  string AlternateMark;
      -  if (StringMark == "ML")
      -    AlternateMark = "IL";
      -  else
      -    AlternateMark = "ML";
      +void PIC16Cloner::cloneSharedFunctions(CallGraphNode *CGN) {
       
      -  // Mark all the called functions
      +  // Check all the called functions from ISR.
         for(CallGraphNode::iterator cgn_it = CGN->begin(); 
                     cgn_it != CGN->end(); ++cgn_it) {
            Function *CalledF = cgn_it->second->getFunction();
      @@ -184,31 +208,27 @@
              reportError("Interrupt function (%0) can't be called", Values); 
            }
       
      -     // Has already been mark 
      -     if (CalledF->getSection().find(StringMark) != string::npos) {
      -        // Should we do anything here?
      -     } else {
      -       // Mark now
      -       if (CalledF->getSection().find(AlternateMark) != string::npos) {
      -         // Function is alternatively marked. It should be a shared one.
      -         // Create IL copy. Passing called function as first argument
      -         // and the caller as the second argument.
      -
      -         // Before making IL copy, first ensure that this function has a 
      -         // body. If the function does have a body. It can't be cloned.
      -         // Such a case may occur when the function has been declarated
      -         // in the C source code but its body exists in assembly file.
      -         if (!CalledF->isDeclaration()) {
      -           // FIXME: Not implemented yet. Clone the function here.
      -         }
      -       } else {
      -         // Function is not marked. It should be marked now.
      -         CalledF->setSection(StringMark);
      +     if (CalledF->getSection().find("ML") != string::npos) {
      +       // Function is alternatively marked. It should be a shared one.
      +       // Create IL copy. Passing called function as first argument
      +       // and the caller as the second argument.
      +
      +       // Before making IL copy, first ensure that this function has a 
      +       // body. If the function does have a body. It can't be cloned.
      +       // Such a case may occur when the function has been declarated
      +       // in the C source code but its body exists in assembly file.
      +       if (!CalledF->isDeclaration()) {
      +         cloneFunction(CalledF);
      +         // FIXME: remap all the call sites here.
      +       }  else {
      +         // It is called only from ISR. Still mark it as we need this info
      +         // in code gen while calling intrinsics.Function is not marked.
      +         CalledF->setSection("IL");
              }
            }
      -     // Before going any further mark all the called function by current
      -     // function.
      -     markCallGraph(cgn_it->second ,StringMark);
      +     // Before going any further clone all the shared function reachaable 
      +     // by current function.
      +     cloneSharedFunctions(cgn_it->second);
         } // end of loop of all called functions.
       }
       
      
      Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h?rev=96589&r1=96588&r2=96589&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h (original)
      +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h Thu Feb 18 11:32:25 2010
      @@ -52,6 +52,9 @@
           // Clone the body of a function.
           Function *cloneFunction(Function *F);
       
      +    // Clone all shared functions.
      +    void cloneSharedFunctions(CallGraphNode *isrCGN);
      +
           // Error reporting for PIC16Pass
           void reportError(string ErrorString, vector &Values);
           void reportError(string ErrorString);
      
      
      
      
      From sanjiv.gupta at microchip.com  Thu Feb 18 12:00:35 2010
      From: sanjiv.gupta at microchip.com (Sanjiv Gupta)
      Date: Thu, 18 Feb 2010 18:00:35 -0000
      Subject: [llvm-commits] [llvm] r96591 - in
       /llvm/trunk/lib/Target/PIC16/PIC16Passes: PIC16Cloner.cpp PIC16Cloner.h
      Message-ID: <201002181800.o1II0Z4l006307@zion.cs.uiuc.edu>
      
      Author: sgupta
      Date: Thu Feb 18 12:00:35 2010
      New Revision: 96591
      
      URL: http://llvm.org/viewvc/llvm-project?rev=96591&view=rev
      Log:
      Remap the call sites of a shared function  in interrupt line functions.
      
      Modified:
          llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
          llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
      
      Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp?rev=96591&r1=96590&r2=96591&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp (original)
      +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp Thu Feb 18 12:00:35 2010
      @@ -270,3 +270,27 @@
       }
       
       
      +// Remap the call sites of shared functions, that are in IL.
      +// Change the IL call site of a shared function to its clone.
      +//
      +void PIC16Cloner::
      +remapAllSites(Function *Caller, Function *OrgF, Function *Clone) {
      +  // First find the caller to update. If the caller itself is cloned
      +  // then use the cloned caller. Otherwise use it.
      +  cloned_map_iterator cm_it = ClonedFunctionMap.find(Caller);
      +  if (cm_it != ClonedFunctionMap.end())
      +    Caller = cm_it->second;
      +
      +  // For the lack of a better call site finding mechanism, iterate over 
      +  // all insns to find the uses of original fn.
      +  for (Function::iterator BI = Caller->begin(); BI != Caller->end(); ++BI) {
      +    BasicBlock &BB = *BI;
      +    for (BasicBlock::iterator II = BB.begin(); II != BB.end(); ++II) {
      +      if (II->getNumOperands() > 0 && II->getOperand(0) == OrgF)
      +          II->setOperand(0, Clone);
      +    }
      +  }
      +}
      +
      +
      +
      
      Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h?rev=96591&r1=96590&r2=96591&view=diff
      
      ==============================================================================
      --- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h (original)
      +++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h Thu Feb 18 12:00:35 2010
      @@ -55,6 +55,9 @@
           // Clone all shared functions.
           void cloneSharedFunctions(CallGraphNode *isrCGN);
       
      +    // Remap all call sites to the shared function.
      +    void remapAllSites(Function *Caller, Function *OrgF, Function *Clone);
      +
           // Error reporting for PIC16Pass
           void reportError(string ErrorString, vector &Values);
           void reportError(string ErrorString);
      
      
      
      
      From gohman at apple.com  Thu Feb 18 12:19:17 2010
      From: gohman at apple.com (Dan Gohman)
      Date: Thu, 18 Feb 2010 18:19:17 -0000
      Subject: [llvm-commits] [llvm] r96594 -
      	/llvm/trunk/docs/AdvancedGetElementPtr.html
      Message-ID: <201002181819.o1IIJHt6006982@zion.cs.uiuc.edu>
      
      Author: djg
      Date: Thu Feb 18 12:19:17 2010
      New Revision: 96594
      
      URL: http://llvm.org/viewvc/llvm-project?rev=96594&view=rev
      Log:
      Fix typos Duncan noticed.
      
      Modified:
          llvm/trunk/docs/AdvancedGetElementPtr.html
      
      Modified: llvm/trunk/docs/AdvancedGetElementPtr.html
      URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96594&r1=96593&r2=96594&view=diff
      
      ==============================================================================
      --- llvm/trunk/docs/AdvancedGetElementPtr.html (original)
      +++ llvm/trunk/docs/AdvancedGetElementPtr.html Thu Feb 18 12:19:17 2010
      @@ -51,7 +51,7 @@
       
         

      And, GEP is more concise in common cases.

      -

      However, for of the underlying integer computation implied, there +

      However, for the underlying integer computation implied, there is no difference.

      @@ -141,7 +141,7 @@ assume that the static array type bounds are respected.

      The second sense of being out of bounds is computing an address that's - beyond of the actual underlying allocated object.

      + beyond the actual underlying allocated object.

      With the inbounds keyword, the result value of the GEP is undefined if the address is outside the actual underlying allocated From gohman at apple.com Thu Feb 18 12:22:18 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Feb 2010 18:22:18 -0000 Subject: [llvm-commits] [llvm] r96596 - /llvm/trunk/docs/AdvancedGetElementPtr.html Message-ID: <201002181822.o1IIMIvf007123@zion.cs.uiuc.edu> Author: djg Date: Thu Feb 18 12:22:18 2010 New Revision: 96596 URL: http://llvm.org/viewvc/llvm-project?rev=96596&view=rev Log: Clarify that the rules about object hopping kick in when a pointer is deferenced, rather than when the pointer value is computed. Modified: llvm/trunk/docs/AdvancedGetElementPtr.html Modified: llvm/trunk/docs/AdvancedGetElementPtr.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96596&r1=96595&r2=96596&view=diff ============================================================================== --- llvm/trunk/docs/AdvancedGetElementPtr.html (original) +++ llvm/trunk/docs/AdvancedGetElementPtr.html Thu Feb 18 12:22:18 2010 @@ -44,10 +44,10 @@ where it doesn't do this. With GEP you can avoid this problem.

      Also, GEP carries additional pointer aliasing rules. It's invalid to take a - GEP from one object and address into a different separately allocated - object. IR producers (front-ends) must follow this rule, and consumers - (optimizers, specifically alias analysis) benefit from being able to rely - on it.

      + GEP from one object, address into a different separately allocated + object, and deference it. IR producers (front-ends) must follow this rule, + and consumers (optimizers, specifically alias analysis) benefit from being + able to rely on it.

      And, GEP is more concise in common cases.

      From gohman at apple.com Thu Feb 18 12:22:41 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Feb 2010 18:22:41 -0000 Subject: [llvm-commits] [llvm] r96597 - /llvm/trunk/docs/AdvancedGetElementPtr.html Message-ID: <201002181822.o1IIMfx1007164@zion.cs.uiuc.edu> Author: djg Date: Thu Feb 18 12:22:41 2010 New Revision: 96597 URL: http://llvm.org/viewvc/llvm-project?rev=96597&view=rev Log: Fix a typo. Modified: llvm/trunk/docs/AdvancedGetElementPtr.html Modified: llvm/trunk/docs/AdvancedGetElementPtr.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96597&r1=96596&r2=96597&view=diff ============================================================================== --- llvm/trunk/docs/AdvancedGetElementPtr.html (original) +++ llvm/trunk/docs/AdvancedGetElementPtr.html Thu Feb 18 12:22:41 2010 @@ -45,7 +45,7 @@

      Also, GEP carries additional pointer aliasing rules. It's invalid to take a GEP from one object, address into a different separately allocated - object, and deference it. IR producers (front-ends) must follow this rule, + object, and dereference it. IR producers (front-ends) must follow this rule, and consumers (optimizers, specifically alias analysis) benefit from being able to rely on it.

      From gohman at apple.com Thu Feb 18 12:40:30 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Feb 2010 18:40:30 -0000 Subject: [llvm-commits] [llvm] r96598 - /llvm/trunk/docs/AdvancedGetElementPtr.html Message-ID: <201002181840.o1IIeUbB008124@zion.cs.uiuc.edu> Author: djg Date: Thu Feb 18 12:40:29 2010 New Revision: 96598 URL: http://llvm.org/viewvc/llvm-project?rev=96598&view=rev Log: Clarify that ptrtoint+inttoptr are an alternative to GEP which are not restricted by the GEP rules. Modified: llvm/trunk/docs/AdvancedGetElementPtr.html Modified: llvm/trunk/docs/AdvancedGetElementPtr.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/AdvancedGetElementPtr.html?rev=96598&r1=96597&r2=96598&view=diff ============================================================================== --- llvm/trunk/docs/AdvancedGetElementPtr.html (original) +++ llvm/trunk/docs/AdvancedGetElementPtr.html Thu Feb 18 12:40:29 2010 @@ -200,9 +200,9 @@ to null?
      -

      You can compute an address that way, but you can't use that pointer to - actually access the object if you do, unless the object is managed - outside of LLVM.

      +

      You can compute an address that way, but if you use GEP to do the add, + you can't use that pointer to actually access the object, unless the + object is managed outside of LLVM.

      The underlying integer computation is sufficiently defined; null has a defined value -- zero -- and you can add whatever value you want to it.

      @@ -211,6 +211,11 @@ object with such a pointer. This includes GlobalVariables, Allocas, and objects pointed to by noalias pointers.

      +

      If you really need this functionality, you can do the arithmetic with + explicit integer instructions, and use inttoptr to convert the result to + an address. Most of GEP's special aliasing rules do not apply to pointers + computed from ptrtoint, arithmetic, and inttoptr sequences.

      +
      @@ -219,9 +224,12 @@ that value to one address to compute the other address?
      -

      As with arithmetic on null, You can compute an address that way, but - you can't use that pointer to actually access the object if you do, - unless the object is managed outside of LLVM.

      +

      As with arithmetic on null, You can use GEP to compute an address that + way, but you can't use that pointer to actually access the object if you + do, unless the object is managed outside of LLVM.

      + +

      Also as above, ptrtoint and inttoptr provide an alternative way to do this + which do not have this restriction.

      From gohman at apple.com Thu Feb 18 12:41:52 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Feb 2010 10:41:52 -0800 Subject: [llvm-commits] [llvm] r96526 - in /llvm/trunk/docs: AdvancedGetElementPtr.html index.html In-Reply-To: <4B7D0F7F.4020104@free.fr> References: <201002172247.o1HMl6ZI003439@zion.cs.uiuc.edu> <4B7D0F7F.4020104@free.fr> Message-ID: <713583C5-EA82-4C01-8CE9-3C4F12BB36E9@apple.com> On Feb 18, 2010, at 1:59 AM, Duncan Sands wrote: > Hi Dan, > >> +

      Also, GEP carries additional pointer aliasing rules. It's invalid to take a >> + GEP from one object and address into a different separately allocated >> + object. IR producers (front-ends) must follow this rule, and consumers >> + (optimizers, specifically alias analysis) benefit from being able to rely >> + on it.

      > > are you sure? I thought it was fine to have a GEP point outside an object (and > possibly into another one) as long as you don't try to load from or store to > that object. You're right. I've cleaned up the wording here to make this explicit. > Also, the "no assumptions about where allocated objects are > allocated" rule applies not just to GEP as far as I know. For example, suppose > you have two consecutive "alloca i32", then do a ptrtoint on the first, add 4 > bytes, and do an inttoptr. You cannot assume that the result points into the > second alloca, yet there are no GEP's here. That's true. However, you can do this if you measure the distance dynamically, instead of just assuming 4. With GEP it's not permitted in either case. >> +

      However, for of the underlying integer computation implied, there >> + is no difference.

      > > for of -> for > >> +

      The second sense of being out of bounds is computing an address that's >> + beyond of the actual underlying allocated object.

      > > beyond of -> beyond Fixed. >> +

      With the inbounds keyword, the result value of the GEP is >> + undefined if the address is outside the actual underlying allocated >> + object and not the address one-past-the-end.

      > > Are you sure, I thought only dereferencing such a pointer was the problem... The inbounds keyword applies to the pointer computation itself. inbounds is to GEP as nsw is to add. >> + Can I cast an object's address to integer and add it >> + to null? >> + >> +
      >> +

      You can compute an address that way, but you can't use that pointer to >> + actually access the object if you do, unless the object is managed >> + outside of LLVM.

      >> + >> +

      The underlying integer computation is sufficiently defined; null has a >> + defined value -- zero -- and you can add whatever value you want to it.

      >> + >> +

      However, it's invalid to access (load from or store to) an LLVM-aware >> + object with such a pointer. This includes GlobalVariables, Allocas, and >> + objects pointed to by noalias pointers.

      > > Woah, that's an exciting rule! Has this always been the case? Yep; LLVM has effectively had this rule for a long time. There have been a few bug reports on it; the resolution was that the user code was buggy. It is valid to do this kind of arithmetic if you use ptrtoint+arithmetic+inttoptr instead of GEP though. I've added some text to mention this. >> +

      Instead, you should cast your pointer types and use arrays instead of >> + vectors for addressing. Arrays have the same in-memory representation >> + as vectors, so the addressing is interchangeable.

      > > Hah! See PR1784. Thanks. See my comments there. Thanks for the review! Dan From dalej at apple.com Thu Feb 18 12:51:15 2010 From: dalej at apple.com (Dale Johannesen) Date: Thu, 18 Feb 2010 18:51:15 -0000 Subject: [llvm-commits] [llvm] r96601 - /llvm/trunk/lib/Target/X86/X86FastISel.cpp Message-ID: <201002181851.o1IIpF28008661@zion.cs.uiuc.edu> Author: johannes Date: Thu Feb 18 12:51:15 2010 New Revision: 96601 URL: http://llvm.org/viewvc/llvm-project?rev=96601&view=rev Log: Generate DBG_VALUE from dbg.value intrinsics. These currently comes out as comments but will eventually generate DWARF. Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=96601&r1=96600&r2=96601&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Feb 18 12:51:15 2010 @@ -1161,10 +1161,41 @@ if (!X86SelectAddress(DI->getAddress(), AM)) return false; const TargetInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE); + // FIXME may need to add RegState::Debug to any registers produced, + // although ESP/EBP should be the only ones at the moment. addFullAddress(BuildMI(MBB, DL, II), AM).addImm(0). addMetadata(DI->getVariable()); return true; } + case Intrinsic::dbg_value: { + // FIXME this should eventually be moved to FastISel, when all targets + // are able to cope with DBG_VALUE. There is nothing target dependent here. + DbgValueInst *DI = cast(&I); + const TargetInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE); + Value *V = DI->getValue(); + if (!V) { + // Currently the optimizer can produce this; insert an undef to + // help debugging. Probably the optimizer should not do this. + BuildMI(MBB, DL, II).addReg(0U).addImm(DI->getOffset()). + addMetadata(DI->getVariable()); + } else if (ConstantInt *CI = dyn_cast(V)) { + BuildMI(MBB, DL, II).addImm(CI->getZExtValue()).addImm(DI->getOffset()). + addMetadata(DI->getVariable()); + } else if (ConstantFP *CF = dyn_cast(V)) { + BuildMI(MBB, DL, II).addFPImm(CF).addImm(DI->getOffset()). + addMetadata(DI->getVariable()); + } else if (unsigned Reg = lookUpRegForValue(V)) { + BuildMI(MBB, DL, II).addReg(Reg, RegState::Debug).addImm(DI->getOffset()). + addMetadata(DI->getVariable()); + } else { + // We can't yet handle anything else here because it would require + // generating code, thus altering codegen because of debug info. + // Insert an undef so we can see what we dropped. + BuildMI(MBB, DL, II).addReg(0U).addImm(DI->getOffset()). + addMetadata(DI->getVariable()); + } + return true; + } case Intrinsic::trap: { BuildMI(MBB, DL, TII.get(X86::TRAP)); return true; From dpatel at apple.com Thu Feb 18 13:52:13 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 18 Feb 2010 19:52:13 -0000 Subject: [llvm-commits] [llvm] r96604 - /llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp Message-ID: <201002181952.o1IJqDSK012012@zion.cs.uiuc.edu> Author: dpatel Date: Thu Feb 18 13:52:12 2010 New Revision: 96604 URL: http://llvm.org/viewvc/llvm-project?rev=96604&view=rev Log: Ignore target dependent value in grep search. Modified: llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp Modified: llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2010-02-17-DbgArtificialArg.cpp?rev=96604&r1=96603&r2=96604&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp (original) +++ llvm/trunk/test/FrontendC++/2010-02-17-DbgArtificialArg.cpp Thu Feb 18 13:52:12 2010 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc -g -S %s -o - | grep DW_TAG_pointer_type | grep "i32 458767, metadata .., metadata ..., metadata .., i32 0, i64 64, i64 64, i64 0, i32 64, metadata ..." +// RUN: %llvmgcc -g -S %s -o - | grep DW_TAG_pointer_type | grep "i32 458767, metadata .., metadata ..., metadata .., i32 ., i64 .., i64 .., i64 0, i32 64, metadata ..." // Here, second to last argument "i32 64" indicates that artificial type is set. // Test to artificial attribute attahed to "this" pointer type. // Radar 7655792 and 7655002 From baldrick at free.fr Thu Feb 18 14:44:56 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 18 Feb 2010 21:44:56 +0100 Subject: [llvm-commits] [llvm] r96526 - in /llvm/trunk/docs: AdvancedGetElementPtr.html index.html In-Reply-To: <713583C5-EA82-4C01-8CE9-3C4F12BB36E9@apple.com> References: <201002172247.o1HMl6ZI003439@zion.cs.uiuc.edu> <4B7D0F7F.4020104@free.fr> <713583C5-EA82-4C01-8CE9-3C4F12BB36E9@apple.com> Message-ID: <4B7DA6C8.9010202@free.fr> Hi Dan, >>> + Can I cast an object's address to integer and add it >>> + to null? >>> +
      >>> +
      >>> +

      You can compute an address that way, but you can't use that pointer to >>> + actually access the object if you do, unless the object is managed >>> + outside of LLVM.

      >>> + >>> +

      The underlying integer computation is sufficiently defined; null has a >>> + defined value -- zero -- and you can add whatever value you want to it.

      >>> + >>> +

      However, it's invalid to access (load from or store to) an LLVM-aware >>> + object with such a pointer. This includes GlobalVariables, Allocas, and >>> + objects pointed to by noalias pointers.

      >> Woah, that's an exciting rule! Has this always been the case? > > Yep; LLVM has effectively had this rule for a long time. There have been a few > bug reports on it; the resolution was that the user code was buggy. it's true that this makes the result of getUnderlyingObject meaningful (otherwise you could get the address of an object by doing "GEP null, address_of_object_as_integer", and for this a call to getUnderlyingObject would return "null" rather than "object"). Thanks for cleaning up the doc - and thanks for writing it in the first place! Ciao, Duncan. From dpatel at apple.com Thu Feb 18 14:53:16 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 18 Feb 2010 20:53:16 -0000 Subject: [llvm-commits] [llvm] r96609 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/LLVMContextImpl.h lib/VMCore/Metadata.cpp Message-ID: <201002182053.o1IKrHu8015022@zion.cs.uiuc.edu> Author: dpatel Date: Thu Feb 18 14:53:16 2010 New Revision: 96609 URL: http://llvm.org/viewvc/llvm-project?rev=96609&view=rev Log: Destroy MDNodes gracefully while deleting llvm context. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/VMCore/LLVMContextImpl.h llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=96609&r1=96608&r2=96609&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Thu Feb 18 14:53:16 2010 @@ -75,6 +75,7 @@ MDNode(const MDNode &); // DO NOT IMPLEMENT void operator=(const MDNode &); // DO NOT IMPLEMENT friend class MDNodeOperand; + friend class LLVMContextImpl; /// NumOperands - This many 'MDNodeOperand' items are co-allocated onto the /// end of this MDNode. @@ -106,6 +107,9 @@ // Replace each instance of F from the operand list of this node with T. void replaceOperand(MDNodeOperand *Op, Value *NewVal); ~MDNode(); + // replaceAllOperandsWithNull - This is used while destroying llvm context to + // gracefully delete all nodes. This method replaces all operands with null. + void replaceAllOperandsWithNull(); protected: explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals, Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=96609&r1=96608&r2=96609&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Thu Feb 18 14:53:16 2010 @@ -229,13 +229,23 @@ if (I->second->use_empty()) delete I->second; } - MDNodeSet.clear(); AlwaysOpaqueTy->dropRef(); for (OpaqueTypesTy::iterator I = OpaqueTypes.begin(), E = OpaqueTypes.end(); I != E; ++I) { (*I)->AbstractTypeUsers.clear(); delete *I; } + // Destroy MDNode operands first. + for (FoldingSetIterator I = MDNodeSet.begin(), E = MDNodeSet.end(); + I != E;) { + MDNode *N = &(*I); + ++I; + N->replaceAllOperandsWithNull(); + } + while (!MDNodeSet.empty()) { + MDNode *N = &(*MDNodeSet.begin()); + N->destroy(); + } } }; Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=96609&r1=96608&r2=96609&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Thu Feb 18 14:53:16 2010 @@ -257,6 +257,13 @@ ID.AddPointer(getOperand(i)); } +// replaceAllOperandsWithNull - This is used while destroying llvm context to +// gracefully delete all nodes. This method replaces all operands with null. +void MDNode::replaceAllOperandsWithNull() { + for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands; + Op != E; ++Op) + replaceOperand(Op, 0); +} // Replace value from this node's operand list. void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) { From baldrick at free.fr Thu Feb 18 15:00:51 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 18 Feb 2010 22:00:51 +0100 Subject: [llvm-commits] [llvm] r96609 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/LLVMContextImpl.h lib/VMCore/Metadata.cpp In-Reply-To: <201002182053.o1IKrHu8015022@zion.cs.uiuc.edu> References: <201002182053.o1IKrHu8015022@zion.cs.uiuc.edu> Message-ID: <4B7DAA83.5070003@free.fr> Hi Devang, > void replaceOperand(MDNodeOperand *Op, Value *NewVal); > ~MDNode(); > + // replaceAllOperandsWithNull - This is used while destroying llvm context to > + // gracefully delete all nodes. This method replaces all operands with null. odd indentation in the first comment line. Also, maybe this should be /// for doxygen. Ciao, Duncan. From dpatel at apple.com Thu Feb 18 15:03:37 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 18 Feb 2010 21:03:37 -0000 Subject: [llvm-commits] [llvm] r96610 - /llvm/trunk/include/llvm/Metadata.h Message-ID: <201002182103.o1IL3bU2015577@zion.cs.uiuc.edu> Author: dpatel Date: Thu Feb 18 15:03:36 2010 New Revision: 96610 URL: http://llvm.org/viewvc/llvm-project?rev=96610&view=rev Log: Fix comments. Modified: llvm/trunk/include/llvm/Metadata.h Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=96610&r1=96609&r2=96610&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Thu Feb 18 15:03:36 2010 @@ -104,11 +104,12 @@ FL_Yes = 1 }; - // Replace each instance of F from the operand list of this node with T. + /// replaceOperand - Replace each instance of F from the operand list of this + /// node with T. void replaceOperand(MDNodeOperand *Op, Value *NewVal); ~MDNode(); - // replaceAllOperandsWithNull - This is used while destroying llvm context to - // gracefully delete all nodes. This method replaces all operands with null. + /// replaceAllOperandsWithNull - This is used while destroying llvm context to + /// gracefully delete all nodes. This method replaces all operands with null. void replaceAllOperandsWithNull(); protected: From dpatel at apple.com Thu Feb 18 15:03:50 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 18 Feb 2010 13:03:50 -0800 Subject: [llvm-commits] [llvm] r96609 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/LLVMContextImpl.h lib/VMCore/Metadata.cpp In-Reply-To: <4B7DAA83.5070003@free.fr> References: <201002182053.o1IKrHu8015022@zion.cs.uiuc.edu> <4B7DAA83.5070003@free.fr> Message-ID: <2FE45B9F-DEB1-48E1-A9F2-EBE54365ACFF@apple.com> On Feb 18, 2010, at 1:00 PM, Duncan Sands wrote: > Hi Devang, > >> void replaceOperand(MDNodeOperand *Op, Value *NewVal); >> ~MDNode(); >> + // replaceAllOperandsWithNull - This is used while destroying llvm context to + // gracefully delete all nodes. This method replaces all operands with null. > > odd indentation in the first comment line. Also, maybe this should be /// for > doxygen. > Fixed. - Devang -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100218/df40cacf/attachment.html From gohman at apple.com Thu Feb 18 15:25:54 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Feb 2010 21:25:54 -0000 Subject: [llvm-commits] [llvm] r96611 - in /llvm/trunk: lib/CodeGen/CodePlacementOpt.cpp test/CodeGen/X86/code_placement_eh.ll Message-ID: <201002182125.o1ILPsf0016785@zion.cs.uiuc.edu> Author: djg Date: Thu Feb 18 15:25:53 2010 New Revision: 96611 URL: http://llvm.org/viewvc/llvm-project?rev=96611&view=rev Log: Make CodePlacementOpt detect special EH control flow by checking whether AnalyzeBranch disagrees with the CFG directly, rather than looking for EH_LABEL instructions. EH_LABEL instructions aren't always at the end of the block, due to FP_REG_KILL and other things. This fixes an infinite loop compiling MultiSource/Benchmarks/Bullet. Added: llvm/trunk/test/CodeGen/X86/code_placement_eh.ll Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=96611&r1=96610&r2=96611&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Thu Feb 18 15:25:53 2010 @@ -102,13 +102,6 @@ // Conservatively ignore EH landing pads. if (MBB->isLandingPad()) return false; - // Ignore blocks which look like they might have EH-related control flow. - // At the time of this writing, there are blocks which AnalyzeBranch - // thinks end in single uncoditional branches, yet which have two CFG - // successors. Code in this file is not prepared to reason about such things. - if (!MBB->empty() && MBB->back().isEHLabel()) - return false; - // Aggressively handle return blocks and similar constructs. if (MBB->succ_empty()) return true; @@ -118,6 +111,14 @@ // Make sure the terminator is understood. if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond)) return false; + // Ignore blocks which look like they might have EH-related control flow. + // AnalyzeBranch thinks it knows how to analyze such things, but it doesn't + // recognize the possibility of a control transfer through an unwind. + // Such blocks contain EH_LABEL instructions, however they may be in the + // middle of the block. Instead of searching for them, just check to see + // if the CFG disagrees with AnalyzeBranch. + if (1u + !Cond.empty() != MBB->succ_size()) + return false; // Make sure we have the option of reversing the condition. if (!Cond.empty() && TII->ReverseBranchCondition(Cond)) return false; Added: llvm/trunk/test/CodeGen/X86/code_placement_eh.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/code_placement_eh.ll?rev=96611&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/code_placement_eh.ll (added) +++ llvm/trunk/test/CodeGen/X86/code_placement_eh.ll Thu Feb 18 15:25:53 2010 @@ -0,0 +1,45 @@ +; RUN: llc < %s + +; CodePlacementOpt shouldn't try to modify this loop because +; it involves EH edges. + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" +target triple = "i386-apple-darwin10.0" + +define void @foo() { +invcont5: + br label %bb15 + +.noexc3: ; preds = %bb15 + br i1 undef, label %bb18.i5.i, label %bb15 + +.noexc6.i.i: ; preds = %bb18.i5.i + %tmp2021 = invoke float @cosf(float 0.000000e+00) readonly + to label %bb18.i5.i unwind label %lpad.i.i ; [#uses=0] + +bb18.i5.i: ; preds = %.noexc6.i.i, %bb51.i + %tmp2019 = invoke float @sinf(float 0.000000e+00) readonly + to label %.noexc6.i.i unwind label %lpad.i.i ; [#uses=0] + +lpad.i.i: ; preds = %bb18.i5.i, %.noexc6.i.i + %eh_ptr.i.i = call i8* @llvm.eh.exception() ; [#uses=1] + unreachable + +lpad59.i: ; preds = %bb15 + %eh_ptr60.i = call i8* @llvm.eh.exception() ; [#uses=1] + unreachable + +bb15: ; preds = %.noexc3, %invcont5 + invoke fastcc void @_ZN28btHashedOverlappingPairCacheC2Ev() + to label %.noexc3 unwind label %lpad59.i +} + +declare i8* @llvm.eh.exception() nounwind readonly + +declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind + +declare float @sinf(float) readonly + +declare float @cosf(float) readonly + +declare fastcc void @_ZN28btHashedOverlappingPairCacheC2Ev() align 2 From stoklund at 2pi.dk Thu Feb 18 15:33:05 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 18 Feb 2010 21:33:05 -0000 Subject: [llvm-commits] [llvm] r96613 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/CalcSpillWeights.cpp lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/X86/2008-02-22-ReMatBug.ll test/CodeGen/X86/pr3495-2.ll Message-ID: <201002182133.o1ILX5Oa017123@zion.cs.uiuc.edu> Author: stoklund Date: Thu Feb 18 15:33:05 2010 New Revision: 96613 URL: http://llvm.org/viewvc/llvm-project?rev=96613&view=rev Log: Always normalize spill weights, also for intervals created by spilling. Moderate the weight given to very small intervals. The spill weight given to new intervals created when spilling was not normalized in the same way as the original spill weights calculated by CalcSpillWeights. That meant that restored registers would tend to hang around because they had a much higher spill weight that unspilled registers. This improves the runtime of a few tests by up to 10%, and there are no significant regressions. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll llvm/trunk/test/CodeGen/X86/pr3495-2.ll Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=96613&r1=96612&r2=96613&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Thu Feb 18 15:33:05 2010 @@ -74,6 +74,14 @@ return (isDef + isUse) * powf(10.0F, (float)loopDepth); } + // After summing the spill weights of all defs and uses, the final weight + // should be normalized, dividing the weight of the interval by its size. + // This encourages spilling of intervals that are large and have few uses, + // and discourages spilling of small intervals with many uses. + void normalizeSpillWeight(LiveInterval &li) { + li.weight /= getApproximateInstructionCount(li) + 25; + } + typedef Reg2IntervalMap::iterator iterator; typedef Reg2IntervalMap::const_iterator const_iterator; const_iterator begin() const { return r2iMap_.begin(); } @@ -409,6 +417,9 @@ DenseMap &MBBVRegsMap, std::vector &NewLIs); + // Normalize the spill weight of all the intervals in NewLIs. + void normalizeSpillWeights(std::vector &NewLIs); + static LiveInterval* createInterval(unsigned Reg); void printInstrs(raw_ostream &O) const; Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=96613&r1=96612&r2=96613&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original) +++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Thu Feb 18 15:33:05 2010 @@ -131,10 +131,7 @@ if (Hint.first || Hint.second) li.weight *= 1.01F; - // Divide the weight of the interval by its size. This encourages - // spilling of intervals that are large and have few uses, and - // discourages spilling of small intervals with many uses. - li.weight /= lis->getApproximateInstructionCount(li) * SlotIndex::NUM; + lis->normalizeSpillWeight(li); } } Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=96613&r1=96612&r2=96613&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Feb 18 15:33:05 2010 @@ -1562,6 +1562,12 @@ } } +void +LiveIntervals::normalizeSpillWeights(std::vector &NewLIs) { + for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) + normalizeSpillWeight(*NewLIs[i]); +} + std::vector LiveIntervals:: addIntervalsForSpillsFast(const LiveInterval &li, const MachineLoopInfo *loopInfo, @@ -1739,6 +1745,7 @@ } handleSpilledImpDefs(li, vrm, rc, NewLIs); + normalizeSpillWeights(NewLIs); return NewLIs; } @@ -1814,6 +1821,7 @@ // Insert spills / restores if we are splitting. if (!TrySplit) { handleSpilledImpDefs(li, vrm, rc, NewLIs); + normalizeSpillWeights(NewLIs); return NewLIs; } @@ -1973,6 +1981,7 @@ } handleSpilledImpDefs(li, vrm, rc, RetNewLIs); + normalizeSpillWeights(RetNewLIs); return RetNewLIs; } Modified: llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll?rev=96613&r1=96612&r2=96613&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll Thu Feb 18 15:33:05 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 -stats |& grep {Number of re-materialization} | grep 3 +; RUN: llc < %s -march=x86 -stats |& grep {Number of re-materialization} | grep 2 ; rdar://5761454 %struct.quad_struct = type { i32, i32, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct* } Modified: llvm/trunk/test/CodeGen/X86/pr3495-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr3495-2.ll?rev=96613&r1=96612&r2=96613&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/pr3495-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/pr3495-2.ll Thu Feb 18 15:33:05 2010 @@ -1,4 +1,8 @@ -; RUN: llc < %s -march=x86 -relocation-model=pic -disable-fp-elim -stats |& grep {Number of reloads omited} +; RUN: llc < %s -march=x86 -relocation-model=pic -disable-fp-elim -stats |& grep {Number of loads added} | grep 1 +; PR3495 +; +; This test may not be testing what it was supposed to test. +; It used to have two spills and four reloads, but not it only has one spill and one reload. target datalayout = "e-p:32:32:32" target triple = "i386-apple-darwin9.6" From gohman at apple.com Thu Feb 18 15:34:02 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Feb 2010 21:34:02 -0000 Subject: [llvm-commits] [llvm] r96614 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <201002182134.o1ILY2g7017169@zion.cs.uiuc.edu> Author: djg Date: Thu Feb 18 15:34:02 2010 New Revision: 96614 URL: http://llvm.org/viewvc/llvm-project?rev=96614&view=rev Log: Hoist this loop-invariant logic out of the loop. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=96614&r1=96613&r2=96614&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Feb 18 15:34:02 2010 @@ -241,15 +241,17 @@ while ((PN = dyn_cast(BBI++))) { if (PN->use_empty()) continue; // dead use, don't replace it + + // SCEV only supports integer expressions for now. + if (!PN->getType()->isIntegerTy() && !PN->getType()->isPointerTy()) + continue; + // Iterate over all of the values in all the PHI nodes. for (unsigned i = 0; i != NumPreds; ++i) { // If the value being merged in is not integer or is not defined // in the loop, skip it. Value *InVal = PN->getIncomingValue(i); - if (!isa(InVal) || - // SCEV only supports integer expressions for now. - (!InVal->getType()->isIntegerTy() && - !InVal->getType()->isPointerTy())) + if (!isa(InVal)) continue; // If this pred is for a subloop, not L itself, skip it. From evan.cheng at apple.com Thu Feb 18 15:39:02 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Feb 2010 13:39:02 -0800 Subject: [llvm-commits] [llvm] r96613 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/CalcSpillWeights.cpp lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/X86/2008-02-22-ReMatBug.ll test/CodeGen/X86/pr3495-2.ll In-Reply-To: <201002182133.o1ILX5Oa017123@zion.cs.uiuc.edu> References: <201002182133.o1ILX5Oa017123@zion.cs.uiuc.edu> Message-ID: On Feb 18, 2010, at 1:33 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Thu Feb 18 15:33:05 2010 > New Revision: 96613 > > URL: http://llvm.org/viewvc/llvm-project?rev=96613&view=rev > Log: > Always normalize spill weights, also for intervals created by spilling. > > Moderate the weight given to very small intervals. > > The spill weight given to new intervals created when spilling was not > normalized in the same way as the original spill weights calculated by > CalcSpillWeights. That meant that restored registers would tend to hang around > because they had a much higher spill weight that unspilled registers. > > This improves the runtime of a few tests by up to 10%, and there are no > significant regressions. Nice. > > > > + // After summing the spill weights of all defs and uses, the final weight > + // should be normalized, dividing the weight of the interval by its size. > + // This encourages spilling of intervals that are large and have few uses, > + // and discourages spilling of small intervals with many uses. > + void normalizeSpillWeight(LiveInterval &li) { > + li.weight /= getApproximateInstructionCount(li) + 25; > + } > + Why 25? The new meaning of life? :-) Evan > typedef Reg2IntervalMap::iterator iterator; > typedef Reg2IntervalMap::const_iterator const_iterator; > const_iterator begin() const { return r2iMap_.begin(); } > @@ -409,6 +417,9 @@ > DenseMap &MBBVRegsMap, > std::vector &NewLIs); > > + // Normalize the spill weight of all the intervals in NewLIs. > + void normalizeSpillWeights(std::vector &NewLIs); > + > static LiveInterval* createInterval(unsigned Reg); > > void printInstrs(raw_ostream &O) const; > > Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=96613&r1=96612&r2=96613&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original) > +++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Thu Feb 18 15:33:05 2010 > @@ -131,10 +131,7 @@ > if (Hint.first || Hint.second) > li.weight *= 1.01F; > > - // Divide the weight of the interval by its size. This encourages > - // spilling of intervals that are large and have few uses, and > - // discourages spilling of small intervals with many uses. > - li.weight /= lis->getApproximateInstructionCount(li) * SlotIndex::NUM; > + lis->normalizeSpillWeight(li); > } > } > > > Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=96613&r1=96612&r2=96613&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Feb 18 15:33:05 2010 > @@ -1562,6 +1562,12 @@ > } > } > > +void > +LiveIntervals::normalizeSpillWeights(std::vector &NewLIs) { > + for (unsigned i = 0, e = NewLIs.size(); i != e; ++i) > + normalizeSpillWeight(*NewLIs[i]); > +} > + > std::vector LiveIntervals:: > addIntervalsForSpillsFast(const LiveInterval &li, > const MachineLoopInfo *loopInfo, > @@ -1739,6 +1745,7 @@ > } > > handleSpilledImpDefs(li, vrm, rc, NewLIs); > + normalizeSpillWeights(NewLIs); > return NewLIs; > } > > @@ -1814,6 +1821,7 @@ > // Insert spills / restores if we are splitting. > if (!TrySplit) { > handleSpilledImpDefs(li, vrm, rc, NewLIs); > + normalizeSpillWeights(NewLIs); > return NewLIs; > } > > @@ -1973,6 +1981,7 @@ > } > > handleSpilledImpDefs(li, vrm, rc, RetNewLIs); > + normalizeSpillWeights(RetNewLIs); > return RetNewLIs; > } > > > Modified: llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll?rev=96613&r1=96612&r2=96613&view=diff > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll (original) > +++ llvm/trunk/test/CodeGen/X86/2008-02-22-ReMatBug.ll Thu Feb 18 15:33:05 2010 > @@ -1,4 +1,4 @@ > -; RUN: llc < %s -march=x86 -stats |& grep {Number of re-materialization} | grep 3 > +; RUN: llc < %s -march=x86 -stats |& grep {Number of re-materialization} | grep 2 > ; rdar://5761454 > > %struct.quad_struct = type { i32, i32, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct*, %struct.quad_struct* } > > Modified: llvm/trunk/test/CodeGen/X86/pr3495-2.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr3495-2.ll?rev=96613&r1=96612&r2=96613&view=diff > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/pr3495-2.ll (original) > +++ llvm/trunk/test/CodeGen/X86/pr3495-2.ll Thu Feb 18 15:33:05 2010 > @@ -1,4 +1,8 @@ > -; RUN: llc < %s -march=x86 -relocation-model=pic -disable-fp-elim -stats |& grep {Number of reloads omited} > +; RUN: llc < %s -march=x86 -relocation-model=pic -disable-fp-elim -stats |& grep {Number of loads added} | grep 1 > +; PR3495 > +; > +; This test may not be testing what it was supposed to test. > +; It used to have two spills and four reloads, but not it only has one spill and one reload. > > target datalayout = "e-p:32:32:32" > target triple = "i386-apple-darwin9.6" > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Thu Feb 18 15:40:44 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Feb 2010 13:40:44 -0800 Subject: [llvm-commits] [llvm] r96613 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/CalcSpillWeights.cpp lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/X86/2008-02-22-ReMatBug.ll test/CodeGen/X86/pr3495-2.ll In-Reply-To: References: <201002182133.o1ILX5Oa017123@zion.cs.uiuc.edu> Message-ID: <7FF33917-499A-475D-AF87-15A738FA2E96@apple.com> On Feb 18, 2010, at 1:39 PM, Evan Cheng wrote: >> >> + // After summing the spill weights of all defs and uses, the final weight >> + // should be normalized, dividing the weight of the interval by its size. >> + // This encourages spilling of intervals that are large and have few uses, >> + // and discourages spilling of small intervals with many uses. >> + void normalizeSpillWeight(LiveInterval &li) { >> + li.weight /= getApproximateInstructionCount(li) + 25; >> + } >> + > > Why 25? The new meaning of life? :-) Is 25 "scientific"? :) -Chris From viridia at gmail.com Thu Feb 18 15:43:45 2010 From: viridia at gmail.com (Talin) Date: Thu, 18 Feb 2010 21:43:45 -0000 Subject: [llvm-commits] [llvm] r96616 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <201002182143.o1ILhj77017591@zion.cs.uiuc.edu> Author: talin Date: Thu Feb 18 15:43:45 2010 New Revision: 96616 URL: http://llvm.org/viewvc/llvm-project?rev=96616&view=rev Log: replaceUsesOfWithOnConstant implementation for unions. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=96616&r1=96615&r2=96616&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Thu Feb 18 15:43:45 2010 @@ -2113,7 +2113,52 @@ void ConstantUnion::replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) { - assert(false && "Implement replaceUsesOfWithOnConstant for unions"); + assert(isa(To) && "Cannot make Constant refer to non-constant!"); + Constant *ToC = cast(To); + + assert(U == OperandList && "Union constants can only have one use!"); + assert(getNumOperands() == 1 && "Union constants can only have one use!"); + assert(getOperand(0) == From && "ReplaceAllUsesWith broken!"); + + std::pair Lookup; + Lookup.first.first = getType(); + Lookup.second = this; + Lookup.first.second = ToC; + + LLVMContext &Context = getType()->getContext(); + LLVMContextImpl *pImpl = Context.pImpl; + + Constant *Replacement = 0; + if (ToC->isNullValue()) { + Replacement = ConstantAggregateZero::get(getType()); + } else { + // Check to see if we have this union type already. + bool Exists; + LLVMContextImpl::UnionConstantsTy::MapTy::iterator I = + pImpl->UnionConstants.InsertOrGetItem(Lookup, Exists); + + if (Exists) { + Replacement = I->second; + } else { + // Okay, the new shape doesn't exist in the system yet. Instead of + // creating a new constant union, inserting it, replaceallusesof'ing the + // old with the new, then deleting the old... just update the current one + // in place! + pImpl->UnionConstants.MoveConstantToNewSlot(this, I); + + // Update to the new value. + setOperand(0, ToC); + return; + } + } + + assert(Replacement != this && "I didn't contain From!"); + + // Everyone using this now uses the replacement. + uncheckedReplaceAllUsesWith(Replacement); + + // Delete the old constant! + destroyConstant(); } void ConstantVector::replaceUsesOfWithOnConstant(Value *From, Value *To, From nlewycky at google.com Thu Feb 18 15:52:02 2010 From: nlewycky at google.com (nlewycky at google.com) Date: Thu, 18 Feb 2010 21:52:02 +0000 Subject: [llvm-commits] [PATCH] Shared library for LLVM (issue198059) Message-ID: <0016e644d67a19c374047fe6faa7@google.com> http://codereview.appspot.com/198059/diff/9002/10008 File Makefile.rules (right): http://codereview.appspot.com/198059/diff/9002/10008#newcode616 Makefile.rules:616: LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib' We should give packagers a flag to tune the rpath path to work around any problems -- or more importantly, turn it off entirely. The libraries should be findable through normal ldconfig lookup once installed. http://codereview.appspot.com/198059/diff/9002/10008#newcode962 Makefile.rules:962: LLVMLibsPaths += $(LibDir)/libLLVM-$(LLVMVersion)$(SHLIBEXT) I don't follow; examples are linked shared even when shared library is off? Or is SHLIBEXT the static extension when shared libraries are disabled? http://codereview.appspot.com/198059/diff/9002/10004 File configure (right): http://codereview.appspot.com/198059/diff/9002/10004#newcode1406 configure:1406: --enable-shared Link LLVM tools shared (default is NO) This sounds independent of whether it builds shared at all. If so, is there a control for that? http://codereview.appspot.com/198059/diff/9002/10006 File tools/llvm-shlib/Makefile (right): http://codereview.appspot.com/198059/diff/9002/10006#newcode64 tools/llvm-shlib/Makefile:64: # at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133. FYI, gcc prefers 'http://gcc.gnu.org/PR40133' style links. They have switched bug database software once before. http://codereview.appspot.com/198059/diff/9002/10007 File unittests/Makefile.unittest (right): http://codereview.appspot.com/198059/diff/9002/10007#newcode32 unittests/Makefile.unittest:32: Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)" Oh, it's either this or try modifying the rpath, huh? And if you make the rpath configurable you're stuck not knowing whether it's relative or absolute. Well, please add a comment here explaining why you don't just fix up the rpath. http://codereview.appspot.com/198059/diff/9002/10007#newcode45 unittests/Makefile.unittest:45: $(Run.Shared) $(LLVMUnitTestExe) The nasty part is that this makes it harder for me to run the unit tests, or to just run the binary under gdb, etc. Without fixing up rpath, there's nothing you can do about that. Then again, you don't really want to install unit tests, and you are very unlikely to want to run them against the installed libraries... maybe we could clobber the rpath instead? http://codereview.appspot.com/198059/show From stoklund at 2pi.dk Thu Feb 18 15:54:07 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 18 Feb 2010 13:54:07 -0800 Subject: [llvm-commits] [llvm] r96613 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/CalcSpillWeights.cpp lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/X86/2008-02-22-ReMatBug.ll test/CodeGen/X86/pr3495-2.ll In-Reply-To: <7FF33917-499A-475D-AF87-15A738FA2E96@apple.com> References: <201002182133.o1ILX5Oa017123@zion.cs.uiuc.edu> <7FF33917-499A-475D-AF87-15A738FA2E96@apple.com> Message-ID: <96CB0796-B87D-4E52-9C6A-346C6EE68DE3@2pi.dk> On Feb 18, 2010, at 1:40 PM, Chris Lattner wrote: > > On Feb 18, 2010, at 1:39 PM, Evan Cheng wrote: > >>> >>> + // After summing the spill weights of all defs and uses, the final weight >>> + // should be normalized, dividing the weight of the interval by its size. >>> + // This encourages spilling of intervals that are large and have few uses, >>> + // and discourages spilling of small intervals with many uses. >>> + void normalizeSpillWeight(LiveInterval &li) { >>> + li.weight /= getApproximateInstructionCount(li) + 25; >>> + } >>> + >> >> Why 25? The new meaning of life? :-) > > Is 25 "scientific"? :) Yes, 25 is chosen as the square of the number of digits on the human hand. :-) The normalized weight is calculated as a use density. The +25 makes the calculation more smooth for small intervals - an interval with one instruction doesn't deserve double the weight of one with two instructions. I don't think the exact number is going to make a big difference, but it does happen to work well for one case I cared about. /jakob From sabre at nondot.org Thu Feb 18 16:03:03 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Feb 2010 22:03:03 -0000 Subject: [llvm-commits] [llvm] r96617 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelMatcher.cpp utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002182203.o1IM33OI018550@zion.cs.uiuc.edu> Author: lattner Date: Thu Feb 18 16:03:03 2010 New Revision: 96617 URL: http://llvm.org/viewvc/llvm-project?rev=96617&view=rev Log: add support for referencing registers and immediates, building the tree to represent them but not emitting table entries for them yet. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/utils/TableGen/DAGISelMatcher.cpp llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96617&r1=96616&r2=96617&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Thu Feb 18 16:03:03 2010 @@ -203,7 +203,7 @@ enum BuiltinOpcodes { OPC_Emit, OPC_Push, - OPC_Record, + OPC_RecordNode, OPC_MoveChild, OPC_MoveParent, OPC_CheckSame, @@ -294,7 +294,7 @@ MatchScopes.push_back(NewEntry); continue; } - case OPC_Record: + case OPC_RecordNode: // Remember this node, it may end up being an operand in the pattern. RecordedNodes.push_back(N); continue; Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=96617&r1=96616&r2=96617&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Thu Feb 18 16:03:03 2010 @@ -10,6 +10,7 @@ #include "DAGISelMatcher.h" #include "CodeGenDAGPatterns.h" #include "CodeGenTarget.h" +#include "Record.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -117,3 +118,19 @@ OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n"; printNext(OS, indent); } + +void EmitIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "EmitIntegerMatcherNode " << Val << " VT=" << VT << '\n'; + printNext(OS, indent); +} + +void EmitRegisterMatcherNode::print(raw_ostream &OS, unsigned indent) const { + OS.indent(indent) << "EmitRegisterMatcherNode "; + if (Reg) + OS << Reg->getName(); + else + OS << "zero_reg"; + OS << " VT=" << VT << '\n'; + printNext(OS, indent); +} + Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96617&r1=96616&r2=96617&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Thu Feb 18 16:03:03 2010 @@ -21,6 +21,7 @@ class PatternToMatch; class raw_ostream; class ComplexPattern; + class Record; MatcherNode *ConvertPatternToMatcher(const PatternToMatch &Pattern, const CodeGenDAGPatterns &CGP); @@ -36,25 +37,31 @@ OwningPtr Next; public: enum KindTy { - EmitNode, - Push, // [Push, Dest0, Dest1, Dest2, Dest3] - Record, // [Record] - MoveChild, // [MoveChild, Child#] - MoveParent, // [MoveParent] + // Stack manipulation. + Push, // Push a checking scope. + RecordNode, // Record the current node. + MoveChild, // Move current node to specified child. + MoveParent, // Move current node to parent. - CheckSame, // [CheckSame, N] Fail if not same as prev match. + // Predicate checking. + CheckSame, // Fail if not same as prev match. CheckPatternPredicate, - CheckPredicate, // [CheckPredicate, P] Fail if predicate fails. - CheckOpcode, // [CheckOpcode, Opcode] Fail if not opcode. - CheckType, // [CheckType, MVT] Fail if not correct type. - CheckInteger, // [CheckInteger, int0,int1,int2,...int7] Fail if wrong val. - CheckCondCode, // [CheckCondCode, CondCode] Fail if not condcode. + CheckPredicate, // Fail if node predicate fails. + CheckOpcode, // Fail if not opcode. + CheckType, // Fail if not correct type. + CheckInteger, // Fail if wrong val. + CheckCondCode, // Fail if not condcode. CheckValueType, CheckComplexPat, CheckAndImm, CheckOrImm, CheckFoldableChainNode, - CheckChainCompatible + CheckChainCompatible, + + // Node creation/emisssion. + EmitInteger, // Create a TargetConstant + EmitRegister, // Create a register. + EmitNode }; const KindTy Kind; @@ -77,23 +84,6 @@ void printNext(raw_ostream &OS, unsigned indent) const; }; -/// EmitNodeMatcherNode - This signals a successful match and generates a node. -class EmitNodeMatcherNode : public MatcherNode { - const PatternToMatch &Pattern; -public: - EmitNodeMatcherNode(const PatternToMatch &pattern) - : MatcherNode(EmitNode), Pattern(pattern) {} - - const PatternToMatch &getPattern() const { return Pattern; } - - static inline bool classof(const MatcherNode *N) { - return N->getKind() == EmitNode; - } - - virtual void print(raw_ostream &OS, unsigned indent = 0) const; -}; - - /// PushMatcherNode - This pushes a failure scope on the stack and evaluates /// 'Next'. If 'Next' fails to match, it pops its scope and attempts to /// match 'Failure'. @@ -123,12 +113,12 @@ std::string WhatFor; public: RecordMatcherNode(const std::string &whatfor) - : MatcherNode(Record), WhatFor(whatfor) {} + : MatcherNode(RecordNode), WhatFor(whatfor) {} const std::string &getWhatFor() const { return WhatFor; } static inline bool classof(const MatcherNode *N) { - return N->getKind() == Record; + return N->getKind() == RecordNode; } virtual void print(raw_ostream &OS, unsigned indent = 0) const; @@ -388,8 +378,60 @@ virtual void print(raw_ostream &OS, unsigned indent = 0) const; }; +/// EmitIntegerMatcherNode - This creates a new TargetConstant. +class EmitIntegerMatcherNode : public MatcherNode { + int64_t Val; + MVT::SimpleValueType VT; +public: + EmitIntegerMatcherNode(int64_t val, MVT::SimpleValueType vt) + : MatcherNode(EmitInteger), Val(val), VT(vt) {} + + int64_t getVal() const { return Val; } + MVT::SimpleValueType getVT() const { return VT; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == EmitInteger; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// EmitRegisterMatcherNode - This creates a new TargetConstant. +class EmitRegisterMatcherNode : public MatcherNode { + /// Reg - The def for the register that we're emitting. If this is null, then + /// this is a reference to zero_reg. + Record *Reg; + MVT::SimpleValueType VT; +public: + EmitRegisterMatcherNode(Record *reg, MVT::SimpleValueType vt) + : MatcherNode(EmitRegister), Reg(reg), VT(vt) {} + + Record *getReg() const { return Reg; } + MVT::SimpleValueType getVT() const { return VT; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == EmitRegister; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; + +/// EmitNodeMatcherNode - This signals a successful match and generates a node. +class EmitNodeMatcherNode : public MatcherNode { + const PatternToMatch &Pattern; +public: + EmitNodeMatcherNode(const PatternToMatch &pattern) + : MatcherNode(EmitNode), Pattern(pattern) {} + + const PatternToMatch &getPattern() const { return Pattern; } + + static inline bool classof(const MatcherNode *N) { + return N->getKind() == EmitNode; + } + + virtual void print(raw_ostream &OS, unsigned indent = 0) const; +}; - } // end namespace llvm #endif Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96617&r1=96616&r2=96617&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Thu Feb 18 16:03:03 2010 @@ -125,8 +125,8 @@ << *cast(N)->getPattern().getDstPattern() << "\n"; OS.PadToColumn(Indent*2) << "OPC_Emit, /*XXX*/\n\n"; return 1; - case MatcherNode::Record: - OS << "OPC_Record,"; + case MatcherNode::RecordNode: + OS << "OPC_RecordNode,"; OS.PadToColumn(CommentIndent) << "// " << cast(N)->getWhatFor() << '\n'; return 1; @@ -212,6 +212,11 @@ OS << "OPC_CheckChainCompatible, " << cast(N)->getPreviousOp() << ",\n"; return 2; + + case MatcherNode::EmitInteger: + case MatcherNode::EmitRegister: + // FIXME: Implement. + return 0; } assert(0 && "Unreachable"); return 0; Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96617&r1=96616&r2=96617&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Thu Feb 18 16:03:03 2010 @@ -397,6 +397,38 @@ void MatcherGen::EmitResultLeafAsOperand(const TreePatternNode *N, SmallVectorImpl &ResultOps) { + assert(N->isLeaf() && "Must be a leaf"); + + if (IntInit *II = dynamic_cast(N->getLeafValue())) { + AddMatcherNode(new EmitIntegerMatcherNode(II->getValue(),N->getTypeNum(0))); + //ResultOps.push_back(TmpNode(TmpNo++)); + return; + } + + // If this is an explicit register reference, handle it. + if (DefInit *DI = dynamic_cast(N->getLeafValue())) { + if (DI->getDef()->isSubClassOf("Register")) { + AddMatcherNode(new EmitRegisterMatcherNode(DI->getDef(), + N->getTypeNum(0))); + //ResultOps.push_back(TmpNode(TmpNo++)); + return; + } + + if (DI->getDef()->getName() == "zero_reg") { + AddMatcherNode(new EmitRegisterMatcherNode(0, N->getTypeNum(0))); + //ResultOps.push_back(TmpNode(TmpNo++)); + return; + } + +#if 0 + if (DI->getDef()->isSubClassOf("RegisterClass")) { + // Handle a reference to a register class. This is used + // in COPY_TO_SUBREG instructions. + // FIXME: Implement. + } +#endif + } + errs() << "unhandled leaf node: \n"; N->dump(); } From johnny.chen at apple.com Thu Feb 18 16:31:18 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 18 Feb 2010 22:31:18 -0000 Subject: [llvm-commits] [llvm] r96619 - in /llvm/trunk/lib/Target/ARM: ARMInstrFormats.td ARMInstrInfo.td Message-ID: <201002182231.o1IMVIgT020160@zion.cs.uiuc.edu> Author: johnny Date: Thu Feb 18 16:31:18 2010 New Revision: 96619 URL: http://llvm.org/viewvc/llvm-project?rev=96619&view=rev Log: Added LDRD_PRE/POST & STRD_PRE/POST for disassembly only. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=96619&r1=96618&r2=96619&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Thu Feb 18 16:31:18 2010 @@ -708,6 +708,20 @@ let Inst{24} = 1; // P bit let Inst{27-25} = 0b000; } +class AI3lddpr pattern> + : I { + let Inst{4} = 1; + let Inst{5} = 0; // H bit + let Inst{6} = 1; // S bit + let Inst{7} = 1; + let Inst{20} = 0; // L bit + let Inst{21} = 1; // W bit + let Inst{24} = 1; // P bit + let Inst{27-25} = 0b000; +} + // Pre-indexed stores class AI3sthpr pattern> + : I { + let Inst{4} = 1; + let Inst{5} = 1; // H bit + let Inst{6} = 1; // S bit + let Inst{7} = 1; + let Inst{20} = 0; // L bit + let Inst{21} = 1; // W bit + let Inst{24} = 1; // P bit + let Inst{27-25} = 0b000; +} // Post-indexed loads class AI3ldhpo pattern> + : I { + let Inst{4} = 1; + let Inst{5} = 0; // H bit + let Inst{6} = 1; // S bit + let Inst{7} = 1; + let Inst{20} = 0; // L bit + let Inst{21} = 0; // W bit + let Inst{24} = 0; // P bit + let Inst{27-25} = 0b000; +} // Post-indexed stores class AI3sthpo pattern> + : I { + let Inst{4} = 1; + let Inst{5} = 1; // H bit + let Inst{6} = 1; // S bit + let Inst{7} = 1; + let Inst{20} = 0; // L bit + let Inst{21} = 0; // W bit + let Inst{24} = 0; // P bit + let Inst{27-25} = 0b000; +} // addrmode4 instructions Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96619&r1=96618&r2=96619&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Feb 18 16:31:18 2010 @@ -1067,6 +1067,19 @@ def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb), (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru, "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>; + +// For disassembly only +def LDRD_PRE : AI3lddpr<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb), + (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadr, + "ldrd", "\t$dst1, $dst2, $addr!", "$addr.base = $base_wb", []>, + Requires<[IsARM, HasV5TE]>; + +// For disassembly only +def LDRD_POST : AI3lddpo<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb), + (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadr, + "ldrd", "\t$dst1, $dst2, [$base], $offset", "$base = $base_wb", []>, + Requires<[IsARM, HasV5TE]>; + } // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only. @@ -1164,6 +1177,20 @@ [(set GPR:$base_wb, (post_truncsti8 GPR:$src, GPR:$base, am2offset:$offset))]>; +// For disassembly only +def STRD_PRE : AI3stdpr<(outs GPR:$base_wb), + (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset), + StMiscFrm, IIC_iStoreru, + "strd", "\t$src1, $src2, [$base, $offset]!", + "$base = $base_wb", []>; + +// For disassembly only +def STRD_POST: AI3stdpo<(outs GPR:$base_wb), + (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset), + StMiscFrm, IIC_iStoreru, + "strd", "\t$src1, $src2, [$base], $offset", + "$base = $base_wb", []>; + // STRT and STRBT are for disassembly only. def STRT : AI2stwpo<(outs GPR:$base_wb), From wangmp at apple.com Thu Feb 18 16:33:18 2010 From: wangmp at apple.com (Mon P Wang) Date: Thu, 18 Feb 2010 22:33:18 -0000 Subject: [llvm-commits] [llvm] r96621 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h test/CodeGen/X86/vec_shuffle-36.ll Message-ID: <201002182233.o1IMXIZ3020284@zion.cs.uiuc.edu> Author: wangmp Date: Thu Feb 18 16:33:18 2010 New Revision: 96621 URL: http://llvm.org/viewvc/llvm-project?rev=96621&view=rev Log: getSplatIndex assumes that the first element of the mask contains the splat index which is not always true if the mask contains undefs. Modified it to return the first non undef value. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=96621&r1=96620&r2=96621&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Thu Feb 18 16:33:18 2010 @@ -1764,7 +1764,12 @@ bool isSplat() const { return isSplatMask(Mask, getValueType(0)); } int getSplatIndex() const { assert(isSplat() && "Cannot get splat index for non-splat!"); - return Mask[0]; + EVT VT = getValueType(0); + for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) { + if (Mask[i] != -1) + return Mask[i]; + } + return -1; } static bool isSplatMask(const int *Mask, EVT VT); Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll?rev=96621&r1=96620&r2=96621&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-36.ll Thu Feb 18 16:33:18 2010 @@ -1,9 +1,16 @@ -; RUN: llc < %s -march=x86 -mattr=sse41 -o %t -; RUN: grep pshufb %t | count 1 - +; RUN: llc < %s -march=x86-64 -mattr=sse41 | FileCheck %s define <8 x i16> @shuf6(<8 x i16> %T0, <8 x i16> %T1) nounwind readnone { +; CHECK: pshufb +; CHECK-NOT: pshufb +; CHECK: ret entry: - %tmp9 = shufflevector <8 x i16> %T0, <8 x i16> %T1, <8 x i32> < i32 3, i32 2, i32 0, i32 2, i32 1, i32 5, i32 6 , i32 undef > - ret <8 x i16> %tmp9 + %tmp9 = shufflevector <8 x i16> %T0, <8 x i16> %T1, <8 x i32> < i32 3, i32 2, i32 0, i32 2, i32 1, i32 5, i32 6 , i32 undef > + ret <8 x i16> %tmp9 } + +define <8 x i16> @shuf7(<8 x i16> %t0) { +; CHECK: pshufd + %tmp10 = shufflevector <8 x i16> %t0, <8 x i16> undef, <8 x i32> < i32 undef, i32 2, i32 2, i32 2, i32 2, i32 2, i32 undef, i32 undef > + ret <8 x i16> %tmp10 +} \ No newline at end of file From xerxes at zafena.se Thu Feb 18 16:56:27 2010 From: xerxes at zafena.se (Xerxes Ranby) Date: Thu, 18 Feb 2010 23:56:27 +0100 Subject: [llvm-commits] [llvm] r96569 - in /llvm/trunk: Makefile Makefile.config.in Makefile.rules autoconf/configure.ac configure test/Makefile test/Unit/lit.cfg test/Unit/lit.site.cfg.in tools/llvm-shlib/ unittests/Makefile.unittest In-Reply-To: <5d44f72f1002180846i179a9eb0m610f3067b6157e54@mail.gmail.com> References: <201002180443.o1I4h31e021421@zion.cs.uiuc.edu> <4B7D1C39.7050001@zafena.se> <5d44f72f1002180846i179a9eb0m610f3067b6157e54@mail.gmail.com> Message-ID: <4B7DC59B.7060600@zafena.se> Jeffrey Yasskin wrote: > On Thu, Feb 18, 2010 at 2:53 AM, Xerxes R?nby wrote: > >> Jeffrey Yasskin wrote: >> >>> Author: jyasskin >>> Date: Wed Feb 17 22:43:02 2010 >>> New Revision: 96569 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=96569&view=rev >>> Log: >>> Roll back the shared library, r96559. It broke two darwins and arm, mysteriously. >>> >>> >>> >> Hi >> The failure on arm: >> >> llvm[1]: Linking Debug Shared Library LLVM2.7svn.so >> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicAdd(unsigned int volatile*, unsigned int)': >> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:86: undefined reference to `__sync_add_and_fetch_4' >> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicIncrement(unsigned int volatile*)': >> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:60: undefined reference to `__sync_add_and_fetch_4' >> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::AtomicDecrement(unsigned int volatile*)': >> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:73: undefined reference to `__sync_sub_and_fetch_4' >> /wd/buildbot/llvm-arm-linux/llvm/Debug/lib/libLLVMSystem.a(Atomic.o): In function `llvm::sys::CompareAndSwap(unsigned int volatile*, unsigned int, unsigned int)': >> /wd/buildbot/llvm-arm-linux/llvm/lib/System/Atomic.cpp:47: undefined reference to `__sync_val_compare_and_swap_4' >> collect2: ld returned 1 exit status >> >> I have seen something similar about one year ago when we tried to make >> libCompileDriver a shared library: >> http://markmail.org/message/cblcpfmsfab65vue >> >> The issue are that the symbol __sync_add_and_fetch_4 and friends do >> exists in libstdc++ but only in the static version. >> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133 >> Quoted Mikael Pettersson from >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40133#c8 >> " >> 1. g++ links shared libraries with -shared-libgcc, which apparently is >> important whenever exceptions are possible. >> 2. -shared-libgcc by definition excludes the static libgcc from the link >> command. >> 3. Since the __sync__ procedures are only present in the static libgcc, >> it follows that they cannot be used by -shared-libgcc objects like >> libstdc++.so. >> " >> >> A workaround might be to specify -lgcc to force linking in the static >> libstdc++ that contains the missing symbols. >> >> Good news are that it looks like this bug should have been resolved in >> gcc trunk. >> I will do some tests with r96559 applied on arm to see if this can be >> workaround by >> >> a: make the linking work by specifying -lgcc during linking. >> or >> b: upgrade gcc and libstdc++ on the buildbot to a newer version. >> >> Cheers >> Xerxes >> > > Thanks for the explanation of the problem! To work around it, I'm > going to remove -Wl,--no-undefined from the ARM build. I think the > shared library should still find the __sync primitives defined in the > main executable, and we'll get assurance that the library is complete > from builds on non-ARM platforms. > Test results of workarounds +r96559 on llvm trunk using gcc 4.3.3 on ubuntu arm linux with removed --no-undefined from tools/llvm-shlib/Makefile the shared library links! -rwxr-xr-x 1 xerxes xerxes 21640706 2010-02-18 23:50 ../../Release/lib/libLLVM2.7svn.so All examples fail to link llvm[1]: Linking Release executable BrainF (without symbols) /usr/bin/ld: /media/disk/llvm-configure/Release/examples/BrainF: hidden symbol `__sync_val_compare_and_swap_4' in /usr/lib/gcc/arm-linux-gnueabi/4.3.3/libgcc.a(linux-atomic.o) is referenced by DSO with -lgcc LLVMLibsOptions += -lgcc the shared library links! -rwxr-xr-x 1 xerxes xerxes 21658573 2010-02-18 23:46 ../../Release/lib/libLLVM2.7svn.so BrainF Fibonacci Kaleidoscope-Ch2 Kaleidoscope-Ch4 Kaleidoscope-Ch6 ModuleMaker HowToUseJIT Kaleidoscope-Ch3 Kaleidoscope-Ch5 Kaleidoscope-Ch7 ParallelJIT links and run ExceptionDemo fails to link llvm[1]: ======= Finished Linking Release Executable ParallelJIT (without symbols) make[1]: Leaving directory `/media/disk/llvm-configure/examples/ParallelJIT' make[1]: Entering directory `/media/disk/llvm-configure/examples/ExceptionDemo' llvm[1]: Compiling ExceptionDemo.cpp for Release build llvm[1]: Linking Release executable ExceptionDemo (without symbols) /media/disk/llvm-configure/examples/ExceptionDemo/Release/ExceptionDemo.o: In function `ourPersonality': ExceptionDemo.cpp:(.text+0x60c): undefined reference to `_Unwind_GetIP' ExceptionDemo.cpp:(.text+0x7f8): undefined reference to `_Unwind_SetGR' ExceptionDemo.cpp:(.text+0x818): undefined reference to `_Unwind_SetGR' ExceptionDemo.cpp:(.text+0x828): undefined reference to `_Unwind_SetIP' ExceptionDemo.cpp:(.text+0x870): undefined reference to `_Unwind_SetGR' collect2: ld returned 1 exit status make[1]: *** [/media/disk/llvm-configure/Release/examples/ExceptionDemo] Error 1 make[1]: Leaving directory `/media/disk/llvm-configure/examples/ExceptionDemo' make: *** [ExceptionDemo/.makeall] Error 2 So linking in the static -lgcc makes at least the shared library usable on ARM and only adds 18kb to the shared library size, still it needs to be solved how to dynamically link LLVM clients binarys that make use of exceptions. I will keep you updated if this are all fixed when using a newer gcc and libstdc++ on ARM. Cheers Xerxes From gohman at apple.com Thu Feb 18 17:26:38 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Feb 2010 23:26:38 -0000 Subject: [llvm-commits] [llvm] r96626 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <201002182326.o1INQe56023005@zion.cs.uiuc.edu> Author: djg Date: Thu Feb 18 17:26:33 2010 New Revision: 96626 URL: http://llvm.org/viewvc/llvm-project?rev=96626&view=rev Log: Indvars needs to explicitly notify ScalarEvolution when it is replacing a loop exit value, so that if a loop gets deleted, ScalarEvolution isn't stick holding on to dangling SCEVAddRecExprs for that loop. This fixes PR6339. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=96626&r1=96625&r2=96626&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Thu Feb 18 17:26:33 2010 @@ -586,6 +586,11 @@ /// compute a trip count, or if the loop is deleted. void forgetLoop(const Loop *L); + /// forgetValue - This method should be called by the client when it has + /// changed a value in a way that may effect its value, or which may + /// disconnect it from a def-use chain linking it to a loop. + void forgetValue(Value *V); + /// GetMinTrailingZeros - Determine the minimum number of zero bits that S /// is guaranteed to end in (at every loop iteration). It is, at the same /// time, the minimum number of times S is divisible by 2. For example, Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96626&r1=96625&r2=96626&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Feb 18 17:26:33 2010 @@ -3485,6 +3485,35 @@ } } +/// forgetValue - This method should be called by the client when it has +/// changed a value in a way that may effect its value, or which may +/// disconnect it from a def-use chain linking it to a loop. +void ScalarEvolution::forgetValue(Value *V) { + Instruction *I = dyn_cast(V); + if (!I) return; + + // Drop information about expressions based on loop-header PHIs. + SmallVector Worklist; + Worklist.push_back(I); + + SmallPtrSet Visited; + while (!Worklist.empty()) { + I = Worklist.pop_back_val(); + if (!Visited.insert(I)) continue; + + std::map::iterator It = + Scalars.find(static_cast(I)); + if (It != Scalars.end()) { + ValuesAtScopes.erase(It->second); + Scalars.erase(It); + if (PHINode *PN = dyn_cast(I)) + ConstantEvolutionLoopExitValue.erase(PN); + } + + PushDefUseChildren(I, Worklist); + } +} + /// ComputeBackedgeTakenCount - Compute the number of times the backedge /// of the specified loop will execute. ScalarEvolution::BackedgeTakenInfo Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=96626&r1=96625&r2=96626&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Feb 18 17:26:33 2010 @@ -246,6 +246,13 @@ if (!PN->getType()->isIntegerTy() && !PN->getType()->isPointerTy()) continue; + // It's necessary to tell ScalarEvolution about this explicitly so that + // it can walk the def-use list and forget all SCEVs, as it may not be + // watching the PHI itself. Once the new exit value is in place, there + // may not be a def-use connection between the loop and every instruction + // which got a SCEVAddRecExpr for that loop. + SE->forgetValue(PN); + // Iterate over all of the values in all the PHI nodes. for (unsigned i = 0; i != NumPreds; ++i) { // If the value being merged in is not integer or is not defined From gohman at apple.com Thu Feb 18 18:05:34 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Feb 2010 00:05:34 -0000 Subject: [llvm-commits] [llvm] r96629 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/lsr-reuse.ll Message-ID: <201002190005.o1J05b3F025084@zion.cs.uiuc.edu> Author: djg Date: Thu Feb 18 18:05:23 2010 New Revision: 96629 URL: http://llvm.org/viewvc/llvm-project?rev=96629&view=rev Log: When determining the set of interesting reuse factors, consider strides in foreign loops. This helps locate reuse opportunities with existing induction variables in foreign loops and reduces the need for inserting new ones. This fixes rdar://7657764. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/test/CodeGen/X86/lsr-reuse.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96629&r1=96628&r2=96629&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Feb 18 18:05:23 2010 @@ -1690,21 +1690,29 @@ void LSRInstance::CollectInterestingTypesAndFactors() { SmallSetVector Strides; - // Collect interesting types and factors. + // Collect interesting types and strides. for (IVUsers::const_iterator UI = IU.begin(), E = IU.end(); UI != E; ++UI) { const SCEV *Stride = UI->getStride(); // Collect interesting types. Types.insert(SE.getEffectiveSCEVType(Stride->getType())); - // Collect interesting factors. + // Add the stride for this loop. + Strides.insert(Stride); + + // Add strides for other mentioned loops. + for (const SCEVAddRecExpr *AR = dyn_cast(UI->getOffset()); + AR; AR = dyn_cast(AR->getStart())) + Strides.insert(AR->getStepRecurrence(SE)); + } + + // Compute interesting factors from the set of interesting strides. + for (SmallSetVector::const_iterator + I = Strides.begin(), E = Strides.end(); I != E; ++I) for (SmallSetVector::const_iterator NewStrideIter = - Strides.begin(), SEnd = Strides.end(); NewStrideIter != SEnd; - ++NewStrideIter) { - const SCEV *OldStride = Stride; + next(I); NewStrideIter != E; ++NewStrideIter) { + const SCEV *OldStride = *I; const SCEV *NewStride = *NewStrideIter; - if (OldStride == NewStride) - continue; if (SE.getTypeSizeInBits(OldStride->getType()) != SE.getTypeSizeInBits(NewStride->getType())) { @@ -1726,8 +1734,6 @@ Factors.insert(Factor->getValue()->getValue().getSExtValue()); } } - Strides.insert(Stride); - } // If all uses use the same type, don't bother looking for truncation-based // reuse. Modified: llvm/trunk/test/CodeGen/X86/lsr-reuse.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-reuse.ll?rev=96629&r1=96628&r2=96629&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-reuse.ll (original) +++ llvm/trunk/test/CodeGen/X86/lsr-reuse.ll Thu Feb 18 18:05:23 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86-64 -O3 | FileCheck %s +; RUN: llc < %s -march=x86-64 -O3 -asm-verbose=false | FileCheck %s target datalayout = "e-p:64:64:64" target triple = "x86_64-unknown-unknown" @@ -384,3 +384,59 @@ return: ret void } + +; LSR should use only one indvar for the inner loop. +; rdar://7657764 + +; CHECK: asd: +; CHECK: BB10_5: +; CHECK-NEXT: addl (%r{{[^,]*}},%rdi,4), %e +; CHECK-NEXT: incq %rdi +; CHECK-NEXT: cmpq %rdi, %r{{[^,]*}} +; CHECK-NEXT: jg + +%struct.anon = type { i32, [4200 x i32] } + + at bars = common global [123123 x %struct.anon] zeroinitializer, align 32 ; <[123123 x %struct.anon]*> [#uses=2] + +define i32 @asd(i32 %n) nounwind readonly { +entry: + %0 = icmp sgt i32 %n, 0 ; [#uses=1] + br i1 %0, label %bb.nph14, label %bb5 + +bb.nph14: ; preds = %entry + %tmp18 = zext i32 %n to i64 ; [#uses=1] + br label %bb + +bb: ; preds = %bb3, %bb.nph14 + %indvar16 = phi i64 [ 0, %bb.nph14 ], [ %indvar.next17, %bb3 ] ; [#uses=3] + %s.113 = phi i32 [ 0, %bb.nph14 ], [ %s.0.lcssa, %bb3 ] ; [#uses=2] + %scevgep2526 = getelementptr [123123 x %struct.anon]* @bars, i64 0, i64 %indvar16, i32 0 ; [#uses=1] + %1 = load i32* %scevgep2526, align 4 ; [#uses=2] + %2 = icmp sgt i32 %1, 0 ; [#uses=1] + br i1 %2, label %bb.nph, label %bb3 + +bb.nph: ; preds = %bb + %tmp23 = sext i32 %1 to i64 ; [#uses=1] + br label %bb1 + +bb1: ; preds = %bb.nph, %bb1 + %indvar = phi i64 [ 0, %bb.nph ], [ %tmp19, %bb1 ] ; [#uses=2] + %s.07 = phi i32 [ %s.113, %bb.nph ], [ %4, %bb1 ] ; [#uses=1] + %c.08 = getelementptr [123123 x %struct.anon]* @bars, i64 0, i64 %indvar16, i32 1, i64 %indvar ; [#uses=1] + %3 = load i32* %c.08, align 4 ; [#uses=1] + %4 = add nsw i32 %3, %s.07 ; [#uses=2] + %tmp19 = add i64 %indvar, 1 ; [#uses=2] + %5 = icmp sgt i64 %tmp23, %tmp19 ; [#uses=1] + br i1 %5, label %bb1, label %bb3 + +bb3: ; preds = %bb1, %bb + %s.0.lcssa = phi i32 [ %s.113, %bb ], [ %4, %bb1 ] ; [#uses=2] + %indvar.next17 = add i64 %indvar16, 1 ; [#uses=2] + %exitcond = icmp eq i64 %indvar.next17, %tmp18 ; [#uses=1] + br i1 %exitcond, label %bb5, label %bb + +bb5: ; preds = %bb3, %entry + %s.1.lcssa = phi i32 [ 0, %entry ], [ %s.0.lcssa, %bb3 ] ; [#uses=1] + ret i32 %s.1.lcssa +} From alenhar2 at cs.uiuc.edu Thu Feb 18 18:08:06 2010 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 19 Feb 2010 00:08:06 -0000 Subject: [llvm-commits] [poolalloc] r96630 - in /poolalloc/trunk: include/dsa/DSGraphTraits.h include/dsa/DSNode.h include/dsa/DSSupport.h lib/DSA/ lib/DSA/DataStructure.cpp lib/DSA/Local.cpp lib/DSA/Printer.cpp lib/DSA/TopDownClosure.cpp Message-ID: <201002190008.o1J08BS1025204@zion.cs.uiuc.edu> Author: alenhar2 Date: Thu Feb 18 18:08:04 2010 New Revision: 96630 URL: http://llvm.org/viewvc/llvm-project?rev=96630&view=rev Log: Time region is long since uninteresting. Make pointer tracking byte offset based (handles missaligned pointers, readies for union type inference). Rudarmentary first class aggregate support (partial anyway). Modified: poolalloc/trunk/include/dsa/DSGraphTraits.h poolalloc/trunk/include/dsa/DSNode.h poolalloc/trunk/include/dsa/DSSupport.h poolalloc/trunk/lib/DSA/ (props changed) poolalloc/trunk/lib/DSA/DataStructure.cpp poolalloc/trunk/lib/DSA/Local.cpp poolalloc/trunk/lib/DSA/Printer.cpp poolalloc/trunk/lib/DSA/TopDownClosure.cpp Modified: poolalloc/trunk/include/dsa/DSGraphTraits.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSGraphTraits.h?rev=96630&r1=96629&r2=96630&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSGraphTraits.h (original) +++ poolalloc/trunk/include/dsa/DSGraphTraits.h Thu Feb 18 18:08:04 2010 @@ -34,10 +34,10 @@ DSNodeIterator(NodeTy *N) : Node(N), Offset(0) {} // begin iterator DSNodeIterator(NodeTy *N, bool) : Node(N) { // Create end iterator if (N != 0) { - Offset = N->getNumLinks() << DS::PointerShift; + Offset = N->getNumLinks(); if (Offset == 0 && Node->getForwardNode() && Node->isDeadNode()) // Model Forward link - Offset += DS::PointerSize; + Offset += 1; } else { Offset = 0; } @@ -66,7 +66,7 @@ pointer operator->() const { return operator*(); } _Self& operator++() { // Preincrement - Offset += (1 << DS::PointerShift); + Offset += 1; return *this; } _Self operator++(int) { // Postincrement Modified: poolalloc/trunk/include/dsa/DSNode.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=96630&r1=96629&r2=96630&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSNode.h (original) +++ poolalloc/trunk/include/dsa/DSNode.h Thu Feb 18 18:08:04 2010 @@ -195,28 +195,19 @@ /// hasLink - Return true if this memory object has a link in slot LinkNo /// bool hasLink(unsigned Offset) const { - assert((Offset & ((1 << DS::PointerShift)-1)) == 0 && - "Pointer offset not aligned correctly!"); - unsigned Index = Offset >> DS::PointerShift; - assert(Index < Links.size() && "Link index is out of range!"); - return Links[Index].getNode(); + assert(Offset < Links.size() && "Link index is out of range!"); + return Links[Offset].getNode(); } /// getLink - Return the link at the specified offset. /// DSNodeHandle &getLink(unsigned Offset) { - assert((Offset & ((1 << DS::PointerShift)-1)) == 0 && - "Pointer offset not aligned correctly!"); - unsigned Index = Offset >> DS::PointerShift; - assert(Index < Links.size() && "Link index is out of range!"); - return Links[Index]; + assert(Offset < Links.size() && "Link index is out of range!"); + return Links[Offset]; } const DSNodeHandle &getLink(unsigned Offset) const { - assert((Offset & ((1 << DS::PointerShift)-1)) == 0 && - "Pointer offset not aligned correctly!"); - unsigned Index = Offset >> DS::PointerShift; - assert(Index < Links.size() && "Link index is out of range!"); - return Links[Index]; + assert(Offset < Links.size() && "Link index is out of range!"); + return Links[Offset]; } /// getNumLinks - Return the number of links in a node... @@ -264,17 +255,10 @@ /// instead one of the higher level methods should be used, below. /// void setLink(unsigned Offset, const DSNodeHandle &NH) { - assert((Offset & ((1 << DS::PointerShift)-1)) == 0 && - "Pointer offset not aligned correctly!"); - unsigned Index = Offset >> DS::PointerShift; - assert(Index < Links.size() && "Link index is out of range!"); - Links[Index] = NH; + assert(Offset < Links.size() && "Link index is out of range!"); + Links[Offset] = NH; } - /// getPointerSize - Return the size of a pointer for the current target. - /// - unsigned getPointerSize() const { return DS::PointerSize; } - /// addEdgeTo - Add an edge from the current node to the specified node. This /// can cause merging of nodes in the graph. /// Modified: poolalloc/trunk/include/dsa/DSSupport.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSSupport.h?rev=96630&r1=96629&r2=96630&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSSupport.h (original) +++ poolalloc/trunk/include/dsa/DSSupport.h Thu Feb 18 18:08:04 2010 @@ -30,16 +30,10 @@ class DSGraph; // A graph for a function class ReachabilityCloner; -namespace DS { // FIXME: After the paper, this should get cleaned up - enum { PointerShift = 2, // 64bit ptrs = 3, 32 bit ptrs = 2 - PointerSize = 1 << PointerShift - }; - /// isPointerType - Return true if this first class type is big enough to hold /// a pointer. /// bool isPointerType(const Type *Ty); -} //===----------------------------------------------------------------------===// /// DSNodeHandle - Implement a "handle" to a data structure node that takes care Propchange: poolalloc/trunk/lib/DSA/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Thu Feb 18 18:08:04 2010 @@ -0,0 +1 @@ +.dep.inc Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=96630&r1=96629&r2=96630&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Thu Feb 18 18:08:04 2010 @@ -53,25 +53,6 @@ cl::init(256)); } -#if 0 -#define TIME_REGION(VARNAME, DESC) \ - NamedRegionTimer VARNAME(DESC) -#else -#define TIME_REGION(VARNAME, DESC) -#endif - -using namespace DS; - -// -// Function: DS::isPointerType() -// -// Description: -// This returns whether the given type is a pointer. -// -bool DS::isPointerType(const Type *Ty) { - return isa(Ty); -} - /// isForwarding - Return true if this NodeHandle is forwarding to another /// one. bool DSNodeHandle::isForwarding() const { @@ -587,7 +568,7 @@ // If this node would have to have an unreasonable number of fields, just // collapse it. This can occur for fortran common blocks, which have stupid // things like { [100000000 x double], [1000000 x double] }. - unsigned NumFields = (NewTySize+DS::PointerSize-1) >> DS::PointerShift; + unsigned NumFields = NewTySize; if (NumFields > DSAFieldLimit) { foldNodeCompletely(); return true; @@ -615,7 +596,7 @@ // If this node would have to have an unreasonable number of fields, just // collapse it. This can occur for fortran common blocks, which have stupid // things like { [100000000 x double], [1000000 x double] }. - unsigned NumFields = (NewTySize+Offset+DS::PointerSize-1) >> DS::PointerShift; + unsigned NumFields = NewTySize+Offset; if (NumFields > DSAFieldLimit) { foldNodeCompletely(); return true; @@ -1010,7 +991,7 @@ // Make all of the outgoing links of N now be outgoing links of CurNodeH. // for (unsigned i = 0; i < N->getNumLinks(); ++i) { - DSNodeHandle &Link = N->getLink(i << DS::PointerShift); + DSNodeHandle &Link = N->getLink(i); if (Link.getNode()) { // Compute the offset into the current node at which to // merge this link. In the common case, this is a linear @@ -1021,7 +1002,7 @@ unsigned MergeOffset = 0; DSNode *CN = CurNodeH.getNode(); if (CN->Size != 1) - MergeOffset = ((i << DS::PointerShift)+NOffset) % CN->getSize(); + MergeOffset = (i+NOffset) % CN->getSize(); CN->addEdgeTo(MergeOffset, Link); } } @@ -1148,7 +1129,7 @@ // reason, we must always go through NH. DN = 0; for (unsigned i = 0, e = SN->getNumLinks(); i != e; ++i) { - const DSNodeHandle &SrcEdge = SN->getLink(i << DS::PointerShift); + const DSNodeHandle &SrcEdge = SN->getLink(i); if (!SrcEdge.isNull()) { const DSNodeHandle &DestEdge = getClonedNH(SrcEdge); // Compute the offset into the current node at which to @@ -1160,7 +1141,7 @@ unsigned MergeOffset = 0; DSNode *CN = NH.getNode(); if (CN->getSize() != 1) - MergeOffset = ((i << DS::PointerShift)+NH.getOffset()) % CN->getSize(); + MergeOffset = (i + NH.getOffset()) % CN->getSize(); CN->addEdgeTo(MergeOffset, DestEdge); } } @@ -1354,7 +1335,7 @@ // For this reason, we must always go through NH. DN = 0; for (unsigned i = 0, e = SN->getNumLinks(); i != e; ++i) { - const DSNodeHandle &SrcEdge = SN->getLink(i << DS::PointerShift); + const DSNodeHandle &SrcEdge = SN->getLink(i); if (!SrcEdge.isNull()) { // Compute the offset into the current node at which to // merge this link. In the common case, this is a linear @@ -1364,7 +1345,7 @@ // links at offset zero. DSNode *CN = SCNH.getNode(); unsigned MergeOffset = - ((i << DS::PointerShift)+SCNH.getOffset()) % CN->getSize(); + (i+SCNH.getOffset()) % CN->getSize(); DSNodeHandle Tmp = CN->getLink(MergeOffset); if (!Tmp.isNull()) { @@ -1379,7 +1360,7 @@ unsigned MergeOffset = 0; CN = SCNH.getNode(); - MergeOffset = ((i << DS::PointerShift)+SCNH.getOffset()) %CN->getSize(); + MergeOffset = (i + SCNH.getOffset()) %CN->getSize(); CN->getLink(MergeOffset).mergeWith(Tmp); } } @@ -1586,7 +1567,6 @@ /// The CloneFlags member controls various aspects of the cloning process. /// void DSGraph::cloneInto( DSGraph* G, unsigned CloneFlags) { - TIME_REGION(X, "cloneInto"); assert(G != this && "Cannot clone graph into itself!"); NodeMapTy OldNodeMap; @@ -1831,8 +1811,6 @@ void DSGraph::mergeInGraph(const DSCallSite &CS, std::vector &Args, const DSGraph &Graph, unsigned CloneFlags) { - TIME_REGION(X, "mergeInGraph"); - assert((CloneFlags & DontCloneCallNodes) && "Doesn't support copying of call nodes!"); @@ -2239,8 +2217,6 @@ // we don't have to perform any non-trivial analysis here. // void DSGraph::removeTriviallyDeadNodes(bool updateForwarders) { - TIME_REGION(X, "removeTriviallyDeadNodes"); - if (updateForwarders) { /// NOTE: This code is disabled. This slows down DSA on 177.mesa /// substantially! @@ -2248,26 +2224,22 @@ // Loop over all of the nodes in the graph, calling getNode on each field. // This will cause all nodes to update their forwarding edges, causing // forwarded nodes to be delete-able. - { TIME_REGION(X, "removeTriviallyDeadNodes:node_iterate"); - for (node_iterator NI = node_begin(), E = node_end(); NI != E; ++NI) { - DSNode &N = *NI; - for (unsigned l = 0, e = N.getNumLinks(); l != e; ++l) - N.getLink(l*N.getPointerSize()).getNode(); - } + for (node_iterator NI = node_begin(), E = node_end(); NI != E; ++NI) { + DSNode &N = *NI; + for (unsigned l = 0, e = N.getNumLinks(); l != e; ++l) + N.getLink(l).getNode(); } // NOTE: This code is disabled. Though it should, in theory, allow us to // remove more nodes down below, the scan of the scalar map is incredibly // expensive for certain programs (with large SCCs). In the future, if we can // make the scalar map scan more efficient, then we can reenable this. - { TIME_REGION(X, "removeTriviallyDeadNodes:scalarmap"); - - // Likewise, forward any edges from the scalar nodes. While we are at it, - // clean house a bit. - for (DSScalarMap::iterator I = ScalarMap.begin(),E = ScalarMap.end();I != E;){ - I->second.getNode(); - ++I; - } + + // Likewise, forward any edges from the scalar nodes. While we are at it, + // clean house a bit. + for (DSScalarMap::iterator I = ScalarMap.begin(), E = ScalarMap.end(); I != E;) { + I->second.getNode(); + ++I; } } @@ -2411,8 +2383,6 @@ // merging... removeTriviallyDeadNodes(); - TIME_REGION(X, "removeDeadNodes"); - // FIXME: Merge non-trivially identical call nodes... // Alive - a set that holds all nodes found to be reachable/alive. @@ -2430,10 +2400,9 @@ DSGraph::StripIncompleteBit); // Mark all nodes reachable by (non-global) scalar nodes as alive... -{ TIME_REGION(Y, "removeDeadNodes:scalarscan"); for (DSScalarMap::iterator I = ScalarMap.begin(), E = ScalarMap.end(); - I != E; ++I) - if (isa(I->first)) { // Keep track of global nodes + I != E; ++I) + if (isa (I->first)) { // Keep track of global nodes assert(!I->second.isNull() && "Null global node?"); assert(I->second.getNode()->isGlobalNode() && "Should be a global node!"); GlobalNodes.push_back(std::make_pair(I->first, I->second.getNode())); @@ -2450,7 +2419,6 @@ } else { I->second.getNode()->markReachableNodes(Alive); } -} // The return values are alive as well. for (ReturnNodesTy::iterator I = ReturnNodes.begin(), E = ReturnNodes.end(); @@ -2643,7 +2611,7 @@ unsigned N2Size = N2->getSize(); if (N2Size == 0) return; // No edges to map to. - for (unsigned i = 0, e = N1->getSize(); i < e; i += DS::PointerSize) { + for (unsigned i = 0, e = N1->getSize(); i < e; ++i) { const DSNodeHandle &N1NH = N1->getLink(i); // Don't call N2->getLink if not needed (avoiding crash if N2Idx is not // aligned right). @@ -2724,7 +2692,6 @@ /// nodes reachable from them from the globals graph into the current graph. /// void DSGraph::updateFromGlobalGraph() { - TIME_REGION(X, "updateFromGlobalGraph"); ReachabilityCloner RC(this, GlobalsGraph, 0); // Clone the non-up-to-date global nodes into this graph. Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=96630&r1=96629&r2=96630&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Thu Feb 18 18:08:04 2010 @@ -110,6 +110,8 @@ void visitPtrToIntInst(PtrToIntInst &I); void visitBitCastInst(BitCastInst &I); void visitCmpInst(CmpInst &I); + void visitInsertValueInst(InsertValueInst& I); + void visitExtractValueInst(ExtractValueInst& I); //the nasty ones void visitGetElementPtrInst(User &GEP); @@ -388,7 +390,31 @@ } void GraphBuilder::visitCmpInst(CmpInst &I) { - //Should this merge or not? I don't think so. + //Address can escape through cmps +} + +void GraphBuilder::visitInsertValueInst(InsertValueInst& I) { + setDestTo(I, createNode()->setAllocaMarker()); + + const Type *StoredTy = I.getInsertedValueOperand()->getType(); + DSNodeHandle Dest = getValueDest(I); + Dest.mergeWith(getValueDest(*I.getAggregateOperand())); + + // Mark that the node is written to... + Dest.getNode()->setModifiedMarker(); + + // Ensure a type-record exists... + Dest.getNode()->mergeTypeInfo(StoredTy, 0); //FIXME: calculate offset + Dest.getNode()->foldNodeCompletely(); + + // Avoid adding edges from null, or processing non-"pointer" stores + if (isa(StoredTy)) + Dest.addEdgeTo(getValueDest(*I.getInsertedValueOperand())); +} + +void GraphBuilder::visitExtractValueInst(ExtractValueInst& I) { + assert(0 && "Not supported yet"); + abort(); } void GraphBuilder::visitGetElementPtrInst(User &GEP) { Modified: poolalloc/trunk/lib/DSA/Printer.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Printer.cpp?rev=96630&r1=96629&r2=96630&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Printer.cpp (original) +++ poolalloc/trunk/lib/DSA/Printer.cpp Thu Feb 18 18:08:04 2010 @@ -132,13 +132,13 @@ static bool edgeTargetsEdgeSource(const void *Node, DSNode::const_iterator I) { unsigned O = I.getNode()->getLink(I.getOffset()).getOffset(); - return (O >> DS::PointerShift) != 0; + return O != 0; } static DSNode::const_iterator getEdgeTarget(const DSNode *Node, DSNode::const_iterator I) { unsigned O = I.getNode()->getLink(I.getOffset()).getOffset(); - unsigned LinkNo = O >> DS::PointerShift; + unsigned LinkNo = O; const DSNode *N = *I; DSNode::const_iterator R = N->begin(); for (; LinkNo; --LinkNo) @@ -174,7 +174,7 @@ // Add edge from return node to real destination DSNode *DestNode = I->second.getNode(); - int EdgeDest = I->second.getOffset() >> DS::PointerShift; + int EdgeDest = I->second.getOffset(); if (EdgeDest == 0) EdgeDest = -1; GW.emitEdge(I->first, -1, DestNode, EdgeDest, "arrowtail=tee,color=gray63"); @@ -196,7 +196,7 @@ // Add edge from return node to real destination DSNode *RetNode = I->second.getNode(); - int RetEdgeDest = I->second.getOffset() >> DS::PointerShift;; + int RetEdgeDest = I->second.getOffset(); if (RetEdgeDest == 0) RetEdgeDest = -1; GW.emitEdge((void*)I->first, -1, RetNode, RetEdgeDest, "arrowtail=tee,color=gray63"); @@ -220,7 +220,7 @@ &EdgeSourceCaptions); if (DSNode *N = Call.getRetVal().getNode()) { - int EdgeDest = Call.getRetVal().getOffset() >> DS::PointerShift; + int EdgeDest = Call.getRetVal().getOffset(); if (EdgeDest == 0) EdgeDest = -1; GW.emitEdge(&Call, 0, N, EdgeDest, "color=gray63,tailclip=false"); } @@ -234,7 +234,7 @@ for (unsigned j = 0, e = Call.getNumPtrArgs(); j != e; ++j) if (DSNode *N = Call.getPtrArg(j).getNode()) { - int EdgeDest = Call.getPtrArg(j).getOffset() >> DS::PointerShift; + int EdgeDest = Call.getPtrArg(j).getOffset(); if (EdgeDest == 0) EdgeDest = -1; GW.emitEdge(&Call, j+2, N, EdgeDest, "color=gray63,tailclip=false"); } Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=96630&r1=96629&r2=96630&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Thu Feb 18 18:08:04 2010 @@ -51,7 +51,7 @@ Visited.insert(N); for (unsigned i = 0, e = N->getNumLinks(); i != e; ++i) { - DSNodeHandle &NH = N->getLink(i*N->getPointerSize()); + DSNodeHandle &NH = N->getLink(i); if (DSNode *NN = NH.getNode()) { std::vector Functions; NN->addFullFunctionList(Functions); From alenhar2 at cs.uiuc.edu Thu Feb 18 18:09:53 2010 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 19 Feb 2010 00:09:53 -0000 Subject: [llvm-commits] [poolalloc] r96631 - in /poolalloc/trunk: include/poolalloc/RunTimeAssociate.h lib/PoolAllocate/EntryPointAnalysis.cpp lib/PoolAllocate/EntryPointAnalysis.h lib/PoolAllocate/RunTimeAssociate.cpp Message-ID: <201002190009.o1J09s1Y025289@zion.cs.uiuc.edu> Author: alenhar2 Date: Thu Feb 18 18:09:52 2010 New Revision: 96631 URL: http://llvm.org/viewvc/llvm-project?rev=96631&view=rev Log: Simplify PA down to the bones for safecode and other dynamic points-to clients Added: poolalloc/trunk/include/poolalloc/RunTimeAssociate.h poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.h poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp Added: poolalloc/trunk/include/poolalloc/RunTimeAssociate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/RunTimeAssociate.h?rev=96631&view=auto ============================================================================== --- poolalloc/trunk/include/poolalloc/RunTimeAssociate.h (added) +++ poolalloc/trunk/include/poolalloc/RunTimeAssociate.h Thu Feb 18 18:09:52 2010 @@ -0,0 +1,410 @@ +//===-- RunTimeAssociate.h - Runtime Ptr Association Pass -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This transform changes programs so that pointers have an associated handle +// corrosponding to DSA results. This is a generalization of the Poolalloc +// pass +// +//===----------------------------------------------------------------------===// + +#ifndef _RUNTIMEASSOCIATE_H +#define _RUNTIMEASSOCIATE_H + +#include "llvm/Argument.h" +#include "llvm/Constants.h" +#include "llvm/Instructions.h" +#include "llvm/Pass.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Support/CallSite.h" +#include "llvm/ADT/EquivalenceClasses.h" +#include "llvm/ADT/VectorExtras.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/Support/CommandLine.h" + +#include "dsa/DataStructure.h" + +#include +#include +#include +#include + +namespace llvm { +class DSNode; +class DSGraph; +class Type; +class AllocaInst; +class CallTargetFinder; + +namespace rPA { + +/// FuncInfo - Represent the pool allocation information for one function in +/// the program. Note that many functions must actually be cloned in order +/// for pool allocation to add arguments to the function signature. In this +/// case, the Clone and NewToOldValueMap information identify how the clone +/// maps to the original function... +/// + +class FuncInfo { +public: + FuncInfo(const Function* f, DSGraph* g) : F(f), G(g), Clone(0) { } + + /// F - The function this FuncInfo corresponds to. + /// + const Function *F; + + DSGraph* G; + + /// Clone - The cloned version of the function, if applicable. + /// + Function *Clone; + + /// ArgNodes - The list of DSNodes which have pools passed in as arguments. + /// + std::vector ArgNodes; + + /// PoolDescriptors - The Value* which defines the pool descriptor for this + /// DSNode. Note: This does not necessarily include pool arguments that are + /// passed in because of indirect function calls that are not used in the + /// function. + std::map PoolDescriptors; + + /// NewToOldValueMap - When and if a function needs to be cloned, this map + /// contains a mapping from all of the values in the new function back to + /// the values they correspond to in the old function. + /// + typedef std::map ValueMapTy; + ValueMapTy NewToOldValueMap; + + /// MapValueToOriginal - Given a value in the cloned version of this + /// function, map it back to the original. If the specified value did not + /// exist in the original function (e.g. because it's a pool descriptor), + /// return null. + + Value * MapValueToOriginal(Value * V) const { + ValueMapTy::const_iterator I = NewToOldValueMap.find(V); + return I != NewToOldValueMap.end() ? const_cast (I->second) : 0; + } + + Value* getOldValueIfAvailable(Value* V) { + if (!NewToOldValueMap.empty()) { + // If the NewToOldValueMap is in effect, use it. + ValueMapTy::iterator I = NewToOldValueMap.find(V); + if (I != NewToOldValueMap.end()) + V = I->second; + } + return V; + } + + void UpdateNewToOldValueMap(Value *OldVal, Value *NewV1, Value *NewV2 = 0) { + ValueMapTy::iterator I = NewToOldValueMap.find(OldVal); + assert(I != NewToOldValueMap.end() && "OldVal not found in clone?"); + NewToOldValueMap.insert(std::make_pair(NewV1, I->second)); + if (NewV2) + NewToOldValueMap.insert(std::make_pair(NewV2, I->second)); + NewToOldValueMap.erase(I); + } + + DSNodeHandle& getDSNodeHFor(Value* V) { + return G->getScalarMap()[getOldValueIfAvailable(V)]; + } + +}; + +class PoolInfo { + Value* PrimDesc; + +public: + + void addPrimaryDescriptor(Value* P) { + PrimDesc = P; + } + + void mergeNodeInfo(const DSNode* N) { } + +}; + +} // end rPA namespace + + +/// RTAssociate - Associate handles with pointers +/// + +class RTAssociate : public ModulePass { + + // Type used to represent the pool, will be opaque in this pass + const Type *PoolDescPtrTy, *PoolDescType; + + /// Special Values - Values created by this pass which should be ignored + std::set SpecialValues; + + /// ValueMap - associate pools with values + std::map ValueMap; + + /// NodePoolMap - Find a pool from a DSNode + std::map NodePoolMap; + std::map FunctionInfo; + + ////////////////////////////////////////////////////////////////////////////// + + GlobalVariable* CreateGlobalPool(const DSNode*, Module*); + AllocaInst* CreateLocalPool(const DSNode*, Function&); + Argument* CreateArgPool(const DSNode*, Argument*); + + /// SetupGlobalPools - Create a global for each global dsnode and associate + /// a pool with it + void SetupGlobalPools(Module*, DSGraph*); + + /// setPoolForNode - associate a pool with a dsnode + void setupPoolForNode(const DSNode*, Value*); + + /// getPoolForNode - return a poolinfo for a dsnode + rPA::PoolInfo* getPoolForNode(const DSNode* D) { + return NodePoolMap[D]; + } + + rPA::FuncInfo* getFuncInfo(const Function*); + + rPA::FuncInfo& makeFuncInfo(const Function* F, DSGraph* G); + + Function* MakeFunctionClone(Function& F, rPA::FuncInfo& FI, DSGraph* G); + + /// ProcessCloneBody - Rewrite the body of a transformed function to use + /// pool allocation where appropriate. + /// + void ProcessFunctionBody(Function &Old, Function &New, DSGraph* G, + DataStructures* DS); + + void TransformBody(Function& F, rPA::FuncInfo& FI, DataStructures* DS); + + void replaceCall(CallSite CS, rPA::FuncInfo& FI, DataStructures* DS); + + ////////////////////////////////////////////////////////////////////////////// + +public: + static char ID; + + RTAssociate(); + bool runOnModule(Module &M); + void getAnalysisUsage(AnalysisUsage &AU) const; + + +}; +/* +private: + + + /// GlobalNodes - For each node (with an H marker) in the globals graph, this + /// map contains the global variable that holds the pool descriptor for the + /// node. + std::map GlobalNodes; + std::map CloneToOrigMap; + +public: + + /// GlobalNodes - For each node (with an H marker) in the globals graph, this + /// map contains the global variable that holds the pool descriptor for the + /// node. + //std::map GlobalNodes; + +protected: + std::map FunctionInfo; + DataStructures* Graphs; + +public: + + //DataStructures &getGraphs() const { +// return *Graphs; +// } + + /// getOrigFunctionFromClone - Given a pointer to a function that was cloned + /// from another function, return the original function. If the argument + /// function is not a clone, return null. + + Function *getOrigFunctionFromClone(const Function *F) const { + std::map::const_iterator I = CloneToOrigMap.find(F); + return I != CloneToOrigMap.end() ? I->second : 0; + } + + /// getFuncInfo - Return the FuncInfo object for the specified function. + /// + + rPA::FuncInfo *getFuncInfo(const Function &F) { + std::map::iterator I = FunctionInfo.find(&F); + return I != FunctionInfo.end() ? &I->second : 0; + } + + /// getFuncInfoOrClone - Return the function info object for for the specified + /// function. If this function is a clone of another function, return the + /// function info object for the original function. + + rPA::FuncInfo *getFuncInfoOrClone(const Function &F) { + // If it is cloned or not check it out. + if (rPA::FuncInfo * FI = getFuncInfo(F)) + return FI; + // Maybe this is a function clone? + if (Function * FC = getOrigFunctionFromClone(&F)) + return getFuncInfo(*FC); + return 0; + } + + + /// releaseMemory - When the pool allocator is no longer used, release + /// resources used by it. + + virtual void releaseMemory() { + FunctionInfo.clear(); + GlobalNodes.clear(); + CloneToOrigMap.clear(); + } + + // + // Method: getPool() + // + // Description: + // Returns the pool handle associated with the DSNode in the given function. + // + // Inputs: + // N - The DSNode of the value for which the caller wants a pool handle. + // F - The function in which the value for which we want a pool handle + // exists. + // + // Notes: + // o) The DSNode N may *not* be in the current function. The caller may + // have mapped a value in the cloned function back to the original + // function. + // + + virtual Value * getPool(const DSNode * N, Function & F) { + // + // Grab the structure containg information about the function and its + // clones. + // + rPA::FuncInfo * FI = getFuncInfoOrClone(F); + assert(FI && "Function has no FuncInfoOrClone!\n"); + + // + // Look for a mapping from the DSNode to the pool handle. + // + std::map::iterator I = FI->PoolDescriptors.find(N); + if (I != FI->PoolDescriptors.end()) { + Value * Pool = I->second; + + // + // Now the fun part: + // The specified function could either be a clone or the original + // function. This means that the pool descriptor that is matched with + // the DSNode is: + // o) A constant accessible from both the original function and its + // clones. + // o) A global variable accessible from both the original function and + // its clones. + // o) An allocation accessible only to the function. + // o) A function parameter accessible only to the local function. + // + // In short, we need to filter out the case where we find a pool handle, + // but it's only accessible from a clone and not the original function. + // + assert((isa (Pool) || + isa (Pool) || + isa (Pool) || + isa (Pool)) && + "Pool of unknown type!\n"); + if ((isa (Pool)) || (isa (Pool))) { + return Pool; + } else if (AllocationInst * AI = dyn_cast (Pool)) { + if (AI->getParent()->getParent() == &F) + return Pool; + } else if (Argument * Arg = dyn_cast (Pool)) { + if (Arg->getParent() == &F) + return Pool; + } + } + + // + // We either do not have a pool, or the pool is not accessible from the + // specified function. Return NULL. + // + return 0; + } + + virtual Value * getGlobalPool(const DSNode * Node) { + std::map::iterator I = GlobalNodes.find(Node); + if (I == GlobalNodes.end()) + return 0; + else + return I->second; + } + +protected: + + /// AddPrototypes - Add prototypes for the pool functions to the + /// specified module and update the Pool* instance variables to point to + /// them. + /// + void AddPrototypes(Module*); + +private: + + /// MicroOptimizePoolCalls - Apply any microoptimizations to calls to pool + /// allocation function calls that we can. + void MicroOptimizePoolCalls(); + + /// BuildIndirectFunctionSets - Iterate over the module looking for indirect + /// calls to functions + void BuildIndirectFunctionSets(Module &M); + + /// SetupGlobalPools - Create global pools for all DSNodes in the globals + /// graph which contain heap objects. If a global variable points to a piece + /// of memory allocated from the heap, this pool gets a global lifetime. + /// + /// This method returns true if correct pool allocation of the module cannot + /// be performed because there is no main function for the module and there + /// are global pools. + bool SetupGlobalPools(Module &M); + + /// FindFunctionPoolArgs - In the first pass over the program, we decide which + /// arguments will have to be added for each function, build the FunctionInfo + /// map and recording this info in the ArgNodes set. + void FindFunctionPoolArgs(Function &F); + + /// CreatePools - This inserts alloca instruction in the function for all + /// pools specified in the NodesToPA list. This adds an entry to the + /// PoolDescriptors map for each DSNode. + /// + void CreatePools(Function &F, DSGraph* G, + const std::vector &NodesToPA, + std::map &PoolDescriptors); + + void TransformBody(DSGraph* g, rPA::FuncInfo &fi, + std::multimap &poolUses, + std::multimap &poolFrees, + Function &F); + + /// InitializeAndDestroyPools - This inserts calls to poolinit and pooldestroy + /// into the function to initialize and destroy the pools in the NodesToPA + /// list. + void InitializeAndDestroyPools(Function &F, + const std::vector &NodesToPA, + std::map &PoolDescriptors, + std::multimap &PoolUses, + std::multimap &PoolFrees); + + void InitializeAndDestroyPool(Function &F, const DSNode *Pool, + std::map &PoolDescriptors, + std::multimap &PoolUses, + std::multimap &PoolFrees); + + void CalculateLivePoolFreeBlocks(std::set &LiveBlocks, Value *PD); +}; +*/ + +} + +#endif /* _RUNTIMEASSOCIATE_H */ + Added: poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp?rev=96631&view=auto ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp (added) +++ poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp Thu Feb 18 18:09:52 2010 @@ -0,0 +1,52 @@ +//===-- EntryPointAnalysis.cpp - Entry point Finding Pass -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This is a general way of finding entry points in a system. Simple programs +// will use the main version. Libraries and OS kernels can have more +// specialized versions. This is done as an analysis group to allow more +// convinient opt invocations. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Pass.h" +#include "llvm/Module.h" +#include "llvm/Function.h" + +#include "EntryPointAnalysis.h" + +using namespace llvm; + +EntryPointAnalysis::~EntryPointAnalysis() {} +char EntryPointAnalysis::ID; + +namespace { + + +static RegisterAnalysisGroup A("Entry Point Analysis"); + +class MainEntryPointAnalysis : public ImmutablePass, public EntryPointAnalysis { +public: + static char ID; + + MainEntryPointAnalysis() : ImmutablePass(&ID) { } + + bool isEntryPoint(const llvm::Function* F) const { + return !F->isDeclaration() + && F->hasExternalLinkage() + && F->hasName() && F->getName() == "main"; + } +}; + +char MainEntryPointAnalysis::ID; +RegisterPass B("epa_main", "Identify Main"); +RegisterAnalysisGroup C(B); + + + +} \ No newline at end of file Added: poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.h?rev=96631&view=auto ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.h (added) +++ poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.h Thu Feb 18 18:09:52 2010 @@ -0,0 +1,35 @@ +//===-- EntryPointAnalysis.h - Entry point Finding Pass -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This is a general way of finding entry points in a system. Simple programs +// will use the main version. Libraries and OS kernels can have more +// specialized versions. +// +//===----------------------------------------------------------------------===// + +#ifndef _ENTRYPOINTANALYSIS_H +#define _ENTRYPOINTANALYSIS_H + +namespace llvm { +class Function; +} + +class EntryPointAnalysis { +public: + static char ID; + EntryPointAnalysis() {} + virtual ~EntryPointAnalysis(); + + virtual bool isEntryPoint(const llvm::Function* F) const = 0; +}; + + + +#endif /* _ENTRYPOINTANALYSIS_H */ + Added: poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp?rev=96631&view=auto ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp (added) +++ poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp Thu Feb 18 18:09:52 2010 @@ -0,0 +1,612 @@ +//===-- RunTimeAssociate.cpp - MemHandle Association Pass -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This transform changes programs so that pointers have an associated handle +// corrosponding to DSA results. This is a generalization of the Poolalloc +// pass +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "pa_assoc" + +#include "dsa/DataStructure.h" +#include "dsa/DSGraph.h" +#include "poolalloc/RunTimeAssociate.h" +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Constants.h" +#include "llvm/Attributes.h" +#include "llvm/Support/CFG.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "llvm/Transforms/Utils/Cloning.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" + +#include "EntryPointAnalysis.h" + +#include + +using namespace llvm; +using namespace rPA; + +char RTAssociate::ID = 0; + +namespace { +RegisterPass +X("rtassoc", "Memory handle association"); + +STATISTIC(NumArgsAdded, "Number of function arguments added"); +STATISTIC(MaxArgsAdded, "Maximum function arguments added to one function"); +STATISTIC(NumCloned, "Number of functions cloned"); +STATISTIC(NumPools, "Number of pools allocated"); +} + +//////////////////////////////////////////////////////////////////////////////// +// Helpers +//////////////////////////////////////////////////////////////////////////////// + +static void GetNodesReachableFromGlobals(DSGraph* G, + hash_set &NodesFromGlobals) { + for (DSScalarMap::global_iterator I = G->getScalarMap().global_begin(), + E = G->getScalarMap().global_end(); I != E; ++I) + G->getNodeForValue(*I).getNode()->markReachableNodes(NodesFromGlobals); +} + +static void MarkNodesWhichMustBePassedIn(hash_set &MarkedNodes, + Function &F, DSGraph* G, + EntryPointAnalysis* EPA) { + // All DSNodes reachable from arguments must be passed in... + // Unless this is an entry point to the program + if (!EPA->isEntryPoint(&F)) { + for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); + I != E; ++I) { + DSGraph::ScalarMapTy::iterator AI = G->getScalarMap().find(I); + if (AI != G->getScalarMap().end()) + if (DSNode * N = AI->second.getNode()) + N->markReachableNodes(MarkedNodes); + } + } + + // Marked the returned node as needing to be passed in. + if (DSNode * RetNode = G->getReturnNodeFor(F).getNode()) + RetNode->markReachableNodes(MarkedNodes); + + // Calculate which DSNodes are reachable from globals. If a node is reachable + // from a global, we will create a global pool for it, so no argument passage + // is required. + hash_set NodesFromGlobals; + GetNodesReachableFromGlobals(G, NodesFromGlobals); + + // Remove any nodes reachable from a global. These nodes will be put into + // global pools, which do not require arguments to be passed in. + + for (hash_set::iterator I = NodesFromGlobals.begin(), + E = NodesFromGlobals.end(); I != E; ++I) + MarkedNodes.erase(*I); +} + + +/// FindFunctionPoolArgs - In the first pass over the program, we decide which +/// arguments will have to be added for each function, build the FunctionInfo +/// map and recording this info in the ArgNodes set. +static void FindFunctionPoolArgs(Function &F, FuncInfo& FI, + EntryPointAnalysis* EPA) { + hash_set MarkedNodes; + + if (FI.G->node_begin() == FI.G->node_end()) + return; // No memory activity, nothing is required + + // Find DataStructure nodes which are allocated in pools non-local to the + // current function. This set will contain all of the DSNodes which require + // pools to be passed in from outside of the function. + MarkNodesWhichMustBePassedIn(MarkedNodes, F, FI.G,EPA); + + FI.ArgNodes.insert(FI.ArgNodes.end(), MarkedNodes.begin(), MarkedNodes.end()); +} + + + + + +//////////////////////////////////////////////////////////////////////////////// +// RTAssociate +//////////////////////////////////////////////////////////////////////////////// + +// MakeFunctionClone - If the specified function needs to be modified for pool +// allocation support, make a clone of it, adding additional arguments as +// necessary, and return it. If not, just return null. +// +Function* RTAssociate::MakeFunctionClone(Function &F, FuncInfo& FI, DSGraph* G) { + if (G->node_begin() == G->node_end()) return 0; + + if (FI.ArgNodes.empty()) + return 0; // No need to clone if no pools need to be passed in! + + // Update statistics.. + NumArgsAdded += FI.ArgNodes.size(); + if (MaxArgsAdded < FI.ArgNodes.size()) MaxArgsAdded = FI.ArgNodes.size(); + ++NumCloned; + + // Figure out what the arguments are to be for the new version of the + // function + const FunctionType *OldFuncTy = F.getFunctionType(); + std::vector ArgTys(FI.ArgNodes.size(), PoolDescPtrTy); + ArgTys.reserve(OldFuncTy->getNumParams() + FI.ArgNodes.size()); + + ArgTys.insert(ArgTys.end(), OldFuncTy->param_begin(), OldFuncTy->param_end()); + + // Create the new function prototype + FunctionType *FuncTy = FunctionType::get(OldFuncTy->getReturnType(), ArgTys, + OldFuncTy->isVarArg()); + // Create the new function... + Function *New = Function::Create(FuncTy, Function::InternalLinkage, F.getName()); + New->copyAttributesFrom(&F); + F.getParent()->getFunctionList().insert(&F, New); + + // Set the rest of the new arguments names to be PDa and add entries to the + // pool descriptors map + Function::arg_iterator NI = New->arg_begin(); + for (unsigned i = 0, e = FI.ArgNodes.size(); i != e; ++i, ++NI) { + FI.PoolDescriptors[FI.ArgNodes[i]] = CreateArgPool(FI.ArgNodes[i], NI); + NI->setName("PDa"); + } + + // Map the existing arguments of the old function to the corresponding + // arguments of the new function, and copy over the names. + DenseMap ValueMap; + for (Function::arg_iterator I = F.arg_begin(); + NI != New->arg_end(); ++I, ++NI) { + ValueMap[I] = NI; + NI->setName(I->getName()); + } + + // Perform the cloning. + std::vector Returns; + CloneFunctionInto(New, &F, ValueMap, Returns); + + // + // The CloneFunctionInto() function will copy the parameter attributes + // verbatim. This is incorrect; each attribute should be shifted one so + // that the pool descriptor has no attributes. + // + const AttrListPtr OldAttrs = New->getAttributes(); + if (!OldAttrs.isEmpty()) { + AttrListPtr NewAttrsVector; + for (unsigned index = 0; index < OldAttrs.getNumSlots(); ++index) { + const AttributeWithIndex & PAWI = OldAttrs.getSlot(index); + unsigned argIndex = PAWI.Index; + + // If it's not the return value, move the attribute to the next + // parameter. + if (argIndex) ++argIndex; + + // Add the parameter to the new list. + NewAttrsVector.addAttr(argIndex, PAWI.Attrs); + } + + // Assign the new attributes to the function clone + New->setAttributes(NewAttrsVector); + } + + for (DenseMap::iterator I = ValueMap.begin(), + E = ValueMap.end(); I != E; ++I) + FI.NewToOldValueMap.insert(std::make_pair(I->second, (Value*)I->first)); + + return FI.Clone = New; +} + +RTAssociate::RTAssociate() +: ModulePass((intptr_t) & ID) { } + +void RTAssociate::getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequiredTransitive (); + AU.addRequired (); +} + +bool RTAssociate::runOnModule(Module &M) { + if (M.begin() == M.end()) return false; + + // + // Get references to the DSA information. For SAFECode, we need Top-Down + // DSA. For Automatic Pool Allocation only, we need Bottom-Up DSA. In all + // cases, we need to use the Equivalence-Class version of DSA. + // + DataStructures* Graphs = &getAnalysis (); + EntryPointAnalysis* EPA = &getAnalysis (); + + // PoolDescType = OpaqueType::get(M.getContext()); + PoolDescType = Type::getInt32Ty(M.getContext()); + PoolDescPtrTy = PointerType::getUnqual(PoolDescType); + M.addTypeName("PoolDescriptor", PoolDescType); + + // Create the pools for memory objects reachable by global variables. + SetupGlobalPools(&M, Graphs-> getGlobalsGraph()); + + // Loop over the functions in the original program finding the pool desc. + // arguments necessary for each function that is indirectly callable. + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (!I->isDeclaration() && Graphs->hasDSGraph(*I)) { + FuncInfo & FI = makeFuncInfo(I, Graphs->getDSGraph(*I)); + FindFunctionPoolArgs(*I, FI, EPA); + } + + // Map that maps an original function to its clone + std::map FuncToCloneMap; + + // Now clone a function using the pool arg list obtained in the previous + // pass over the modules. Loop over only the function initially in the + // program, don't traverse newly added ones. If the function needs new + // arguments, make its clone. + std::set ClonedFunctions; + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (!I->isDeclaration() && !ClonedFunctions.count(I) && + Graphs->hasDSGraph(*I)) { + FuncInfo & FI = FunctionInfo.find(I)->second; + if (Function* Clone = MakeFunctionClone(*I, FI, Graphs->getDSGraph(*I))) { + assert(!EPA->isEntryPoint(I) && "Entry Point Cloned"); + FuncToCloneMap[I] = Clone; + ClonedFunctions.insert(Clone); + } + } + + // Now that all call targets are available, rewrite the function bodies of the + // clones. + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (!I->isDeclaration() && !ClonedFunctions.count(I) && + Graphs->hasDSGraph(*I)) { + if (FuncToCloneMap.find(I) == FuncToCloneMap.end()) { + // Function was changed inplace + ProcessFunctionBody(*I, *I, Graphs->getDSGraph(*I),Graphs); + } else { + // Function was cloned + ProcessFunctionBody(*I, *FuncToCloneMap[I], Graphs->getDSGraph(*I), + Graphs); + } + } + + return true; +} + +// SetupGlobalPools - Create global pools for all DSNodes in the globals graph. +// This is implemented by making the pool descriptor be a global variable of +// it's own. + +void RTAssociate::SetupGlobalPools(Module* M, DSGraph* GG) { + // Get the globals graph for the program. + // DSGraph* GG = Graphs->getGlobalsGraph(); + + // Get all of the nodes reachable from globals. + hash_set GlobalHeapNodes; + GetNodesReachableFromGlobals(GG, GlobalHeapNodes); + + std::cerr << "Pool allocating " << GlobalHeapNodes.size() + << " global nodes!\n"; + + FuncInfo& FI = makeFuncInfo(0, GG); + + while (GlobalHeapNodes.size()) { + const DSNode* D = *GlobalHeapNodes.begin(); + GlobalHeapNodes.erase(D); + FI.PoolDescriptors[D] = CreateGlobalPool(D, M); + } +} + +/// CreateGlobalPool - Create a global pool descriptor object + +GlobalVariable* RTAssociate::CreateGlobalPool(const DSNode* D, Module* M) { + //Must use external linkage unless we have an inializer + GlobalVariable *GV = new GlobalVariable(*M, PoolDescType, false, + GlobalValue::ExternalLinkage, 0, + "GlobalPool"); + ++NumPools; + SpecialValues.insert(GV); + return GV; +} + +/// CreatePool - This creates the pool for local DSNodes +/// + +AllocaInst* RTAssociate::CreateLocalPool(const DSNode* D, Function &F) { + AllocaInst* AI = new AllocaInst(PoolDescType, 0, "LocalPool", + F.getEntryBlock().begin()); + ++NumPools; + SpecialValues.insert(AI); + return AI; +} + +Argument* RTAssociate::CreateArgPool(const DSNode*D, Argument* Arg) { + SpecialValues.insert(Arg); + return Arg; +} + +/// setupPoolForNode - Update or merge the pool with the DSNode's info and update +/// node mappings. + +void RTAssociate::setupPoolForNode(const DSNode* D, Value* V) { + SpecialValues.insert(V); + PoolInfo*& PI = NodePoolMap[D]; + assert(!PI && "Pool already exists"); + PI = new PoolInfo(); + PI->addPrimaryDescriptor(V); + PI->mergeNodeInfo(D); + NodePoolMap[D] = PI; +} + +/// ProcessFunctionBody - Pool allocate any data structures which are contained +/// in the specified function. +// + +void RTAssociate::ProcessFunctionBody(Function &F, Function &NewF, DSGraph* G, + DataStructures* DS) { + if (G->node_begin() == G->node_end()) return; // Quick exit if nothing to do. + + FuncInfo &FI = *getFuncInfo(&F); + + // Calculate which DSNodes are reachable from globals. If a node is reachable + // from a global, we will create a global pool for it, so no argument passage + // is required. + G->getGlobalsGraph(); + + // Map all node reachable from this global to the corresponding nodes in + // the globals graph. + DSGraph::NodeMapTy GlobalsGraphNodeMapping; + G->computeGToGGMapping(GlobalsGraphNodeMapping); + + // Loop over all of the nodes which are non-escaping, adding pool-allocatable + // ones to the NodesToPA vector. + for (DSGraph::node_iterator I = G->node_begin(), E = G->node_end(); I != E; ++I) { + DSNode *N = I; + if (GlobalsGraphNodeMapping.count(N)) { + // If it is a global pool, set up the pool descriptor appropriately. + DSNode *GGN = GlobalsGraphNodeMapping[N].getNode(); + assert(getFuncInfo(0)->PoolDescriptors[GGN] && "Should be in global mapping!"); + FI.PoolDescriptors[N] = getFuncInfo(0)->PoolDescriptors[GGN]; + } else if (!FI.PoolDescriptors[N]) { + // Otherwise, if it was not passed in from outside the function, it must + // be a local pool! + assert(!N->isGlobalNode() && "Should be in global mapping!"); + FI.PoolDescriptors[N] = CreateLocalPool(N, NewF); + } + } + TransformBody(NewF, FI, DS); +} + +FuncInfo* RTAssociate::getFuncInfo(const Function* F) { + std::map::iterator I = FunctionInfo.find(F); + return I != FunctionInfo.end() ? &I->second : 0; +} + +FuncInfo& RTAssociate::makeFuncInfo(const Function* F, DSGraph* G) { + return FunctionInfo.insert(std::make_pair(F, FuncInfo(F, G))).first->second; +} + +void RTAssociate::TransformBody(Function& F, FuncInfo& FI, + DataStructures* DS) { + for (Function::iterator ii = F.begin(), ee = F.end(); ii != ee; ++ii) + for (BasicBlock::iterator bi = ii->begin(); bi != ii->end();) + if (CallInst* CI = dyn_cast(bi)) { + ++bi; + replaceCall(CallSite(CI), FI, DS); + } else + ++bi; + } + +void RTAssociate::replaceCall(CallSite CS, FuncInfo& FI, DataStructures* DS) { + const Function *CF = CS.getCalledFunction(); + Instruction *TheCall = CS.getInstruction(); + + // If the called function is casted from one function type to another, peer + // into the cast instruction and pull out the actual function being called. + if (ConstantExpr *CE = dyn_cast(CS.getCalledValue())) + if (CE->getOpcode() == Instruction::BitCast && + isa(CE->getOperand(0))) + CF = cast(CE->getOperand(0)); + + if (isa(TheCall->getOperand(0))) { + std::cerr << "INLINE ASM: ignoring. Hoping that's safe.\n"; + return; + } + + // Ignore calls to NULL pointers. + if (isa(CS.getCalledValue())) { + std::cerr << "WARNING: Ignoring call using NULL function pointer.\n"; + return; + } + // We need to figure out which local pool descriptors correspond to the pool + // descriptor arguments passed into the function call. Calculate a mapping + // from callee DSNodes to caller DSNodes. We construct a partial isomophism + // between the graphs to figure out which pool descriptors need to be passed + // in. The roots of this mapping is found from arguments and return values. + // + DSGraph::NodeMapTy NodeMapping; + Instruction *NewCall; + Value *NewCallee; + std::vector ArgNodes; + DSGraph *CalleeGraph; // The callee graph + + // For indirect callees, find any callee since all DS graphs have been + // merged. + if (CF) { // Direct calls are nice and simple. + DEBUG(std::cerr << " Handling direct call: " << *TheCall); + FuncInfo *CFI = getFuncInfo(CF); + if (CFI == 0 || CFI->Clone == 0) // Nothing to transform... + return; + + NewCallee = CFI->Clone; + ArgNodes = CFI->ArgNodes; + + assert ((DS->hasDSGraph (*CF)) && "Function has no ECGraph!\n"); + CalleeGraph = DS->getDSGraph(*CF); + } else { + DEBUG(std::cerr << " Handling indirect call: " << *TheCall); + + // Here we fill in CF with one of the possible called functions. Because we + // merged together all of the arguments to all of the functions in the + // equivalence set, it doesn't really matter which one we pick. + // (If the function was cloned, we have to map the cloned call instruction + // in CS back to the original call instruction.) + Instruction *OrigInst = + cast(FI.getOldValueIfAvailable(CS.getInstruction())); + + DataStructures::callee_iterator I = DS->callee_begin(OrigInst); + if (I != DS->callee_end(OrigInst)) + CF = *I; + + // If we didn't find the callee in the constructed call graph, try + // checking in the DSNode itself. + // This isn't ideal as it means that this call site didn't have inlining + // happen. + if (!CF) { + DSGraph* dg = DS->getDSGraph(*OrigInst->getParent()->getParent()); + DSNode* d = dg->getNodeForValue(OrigInst->getOperand(0)).getNode(); + assert (d && "No DSNode!\n"); + std::vector g; + d->addFullFunctionList(g); + if (g.size()) { + EquivalenceClasses< const GlobalValue *> & EC = dg->getGlobalECs(); + for(std::vector::const_iterator ii = g.begin(), ee = g.end(); + !CF && ii != ee; ++ii) { + for (EquivalenceClasses::member_iterator MI = EC.findLeader(*ii); + MI != EC.member_end(); ++MI) // Loop over members in this set. + if ((CF = dyn_cast(*MI))) { + break; + } + } + } + } + + // + // Do an assert unless we're bugpointing something. + // +// if ((UsingBugpoint) && (!CF)) return; + assert (CF && "No call graph info"); + + // Get the common graph for the set of functions this call may invoke. +// if (UsingBugpoint && (!(Graphs.hasDSGraph(*CF)))) return; + assert ((DS->hasDSGraph(*CF)) && "Function has no DSGraph!\n"); + CalleeGraph = DS->getDSGraph(*CF); + +#ifndef NDEBUG + // Verify that all potential callees at call site have the same DS graph. + DataStructures::callee_iterator E = DS->callee_end(OrigInst); + for (; I != E; ++I) + if (!(*I)->isDeclaration()) + assert(CalleeGraph == DS->getDSGraph(**I) && + "Callees at call site do not have a common graph!"); +#endif + + // Find the DS nodes for the arguments that need to be added, if any. + FuncInfo *CFI = getFuncInfo(CF); + assert(CFI && "No function info for callee at indirect call?"); + ArgNodes = CFI->ArgNodes; + + if (ArgNodes.empty()) + return; // No arguments to add? Transformation is a noop! + + // Cast the function pointer to an appropriate type! + std::vector ArgTys(ArgNodes.size(), PoolDescPtrTy); + for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); + I != E; ++I) + ArgTys.push_back((*I)->getType()); + + FunctionType *FTy = FunctionType::get(TheCall->getType(), ArgTys, false); + PointerType *PFTy = PointerType::getUnqual(FTy); + + // If there are any pool arguments cast the func ptr to the right type. + NewCallee = CastInst::CreatePointerCast(CS.getCalledValue(), PFTy, "tmp", TheCall); + } + + Function::const_arg_iterator FAI = CF->arg_begin(), E = CF->arg_end(); + CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); + for ( ; FAI != E && AI != AE; ++FAI, ++AI) + if (!isa(*AI)) + DSGraph::computeNodeMapping(CalleeGraph->getNodeForValue(FAI), + FI.getDSNodeHFor(*AI), NodeMapping, false); + + assert(AI == AE && "Varargs calls not handled yet!"); + + // Map the return value as well... + if (isa(TheCall->getType())) + DSGraph::computeNodeMapping(CalleeGraph->getReturnNodeFor(*CF), + FI.getDSNodeHFor(TheCall), NodeMapping, false); + + // Okay, now that we have established our mapping, we can figure out which + // pool descriptors to pass in... + std::vector Args; + for (unsigned i = 0, e = ArgNodes.size(); i != e; ++i) { + Value *ArgVal = Constant::getNullValue(PoolDescPtrTy); + if (NodeMapping.count(ArgNodes[i])) + if (DSNode *LocalNode = NodeMapping[ArgNodes[i]].getNode()) + if (FI.PoolDescriptors.count(LocalNode)) + ArgVal = FI.PoolDescriptors.find(LocalNode)->second; + if (isa (ArgVal) && cast (ArgVal)->isNullValue()) + std::cerr << "WARNING: NULL POOL ARGUMENTS ARE PASSED IN!\n"; + Args.push_back(ArgVal); + } + + // Add the rest of the arguments... + Args.insert(Args.end(), CS.arg_begin(), CS.arg_end()); + + // + // There are circumstances where a function is casted to another type and + // then called (que horible). We need to perform a similar cast if the + // type doesn't match the number of arguments. + // + if (Function * NewFunction = dyn_cast(NewCallee)) { + const FunctionType * NewCalleeType = NewFunction->getFunctionType(); + if (NewCalleeType->getNumParams() != Args.size()) { + std::vector Types; + Type * FuncTy = FunctionType::get (NewCalleeType->getReturnType(), + Types, + true); + FuncTy = PointerType::getUnqual (FuncTy); + NewCallee = new BitCastInst (NewCallee, FuncTy, "", TheCall); + } + } + + std::string Name = TheCall->getName(); TheCall->setName(""); + + if (InvokeInst *II = dyn_cast(TheCall)) { + NewCall = InvokeInst::Create (NewCallee, II->getNormalDest(), + II->getUnwindDest(), + Args.begin(), Args.end(), Name, TheCall); + } else { + NewCall = CallInst::Create (NewCallee, Args.begin(), Args.end(), Name, + TheCall); + } + + TheCall->replaceAllUsesWith(NewCall); + DEBUG(std::cerr << " Result Call: " << *NewCall); + + if (TheCall->getType()->getTypeID() != Type::VoidTyID) { + // If we are modifying the original function, update the DSGraph... + DSGraph::ScalarMapTy &SM = FI.G->getScalarMap(); + DSGraph::ScalarMapTy::iterator CII = SM.find(TheCall); + if (CII != SM.end()) { + SM[NewCall] = CII->second; + SM.erase(CII); // Destroy the CallInst + } else if (!FI.NewToOldValueMap.empty()) { + // Otherwise, if this is a clone, update the NewToOldValueMap with the new + // CI return value. + FI.UpdateNewToOldValueMap(TheCall, NewCall); + } + } else if (!FI.NewToOldValueMap.empty()) { + FI.UpdateNewToOldValueMap(TheCall, NewCall); + } + + //FIXME: attributes on call? + CallSite(NewCall).setCallingConv(CallSite(TheCall).getCallingConv()); + + TheCall->eraseFromParent(); +} \ No newline at end of file From alenhar2 at cs.uiuc.edu Thu Feb 18 18:12:50 2010 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 19 Feb 2010 00:12:50 -0000 Subject: [llvm-commits] [poolalloc] r96632 - in /poolalloc/trunk: include/rPA/ include/rPA/PoolAllocate.h lib/Makefile lib/PoolAllocate/ lib/PoolAllocate/PoolAllocate.cpp lib/PoolAllocate/TransformFunctionBody.cpp lib/rDSA/ tools/Makefile Message-ID: <201002190012.o1J0CqYq025440@zion.cs.uiuc.edu> Author: alenhar2 Date: Thu Feb 18 18:12:39 2010 New Revision: 96632 URL: http://llvm.org/viewvc/llvm-project?rev=96632&view=rev Log: clear out my old cruft (rDSA and rPA) Added: poolalloc/trunk/include/rPA/ - copied from r81344, poolalloc/trunk/include/poolalloc/ Removed: poolalloc/trunk/lib/rDSA/ Modified: poolalloc/trunk/include/rPA/PoolAllocate.h poolalloc/trunk/lib/Makefile poolalloc/trunk/lib/PoolAllocate/ (props changed) poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp poolalloc/trunk/tools/Makefile Modified: poolalloc/trunk/include/rPA/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rPA/PoolAllocate.h?rev=96632&r1=81344&r2=96632&view=diff ============================================================================== --- poolalloc/trunk/include/rPA/PoolAllocate.h (original) +++ poolalloc/trunk/include/rPA/PoolAllocate.h Thu Feb 18 18:12:39 2010 @@ -28,7 +28,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/Support/CommandLine.h" -#include "dsa/DataStructure.h" +#include "rdsa/DataStructure.h" #include "poolalloc/ADT/HashExtras.h" #include "poolalloc/Config/config.h" @@ -134,11 +134,11 @@ virtual const Type * getPoolType() {return 0;} virtual bool hasDSGraph (const Function & F) const { - return Graphs->hasDSGraph (F); + return Graphs->hasDSGraph (&F); } virtual DSGraph* getDSGraph (const Function & F) const { - return Graphs->getDSGraph (F); + return Graphs->getDSGraph (&F); } virtual DSGraph* getGlobalsGraph () const { @@ -149,8 +149,8 @@ virtual Value * getGlobalPool (const DSNode * Node) {return 0;} - virtual DataStructures::callee_iterator callee_begin (Instruction *I) { return Graphs->callee_begin(I);} - virtual DataStructures::callee_iterator callee_end (Instruction *I) { return Graphs->callee_end(I);} + virtual InstCallGraph::iterator callee_begin (Instruction *I) { return Graphs->callee.begin(I);} + virtual InstCallGraph::iterator callee_end (Instruction *I) { return Graphs->callee.end(I);} }; /// PoolAllocate - The main pool allocation pass @@ -283,7 +283,7 @@ } virtual DSGraph* getDSGraph (const Function & F) const { - return Graphs->getDSGraph (F); + return Graphs->getDSGraph (&F); } virtual DSGraph* getGlobalsGraph () const { @@ -367,14 +367,14 @@ return I->second; } - virtual DataStructures::callee_iterator + virtual InstCallGraph::iterator callee_begin (Instruction * I) { - return Graphs->callee_begin(I); + return Graphs->callee.begin(I); } - virtual DataStructures::callee_iterator + virtual InstCallGraph::iterator callee_end (Instruction * I) { - return Graphs->callee_end(I); + return Graphs->callee.end(I); } protected: Modified: poolalloc/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/Makefile?rev=96632&r1=96631&r2=96632&view=diff ============================================================================== --- poolalloc/trunk/lib/Makefile (original) +++ poolalloc/trunk/lib/Makefile Thu Feb 18 18:12:39 2010 @@ -6,6 +6,6 @@ # # List all of the subdirectories that we will compile. # -DIRS=DSA PoolAllocate AssistDS rDSA +DIRS=DSA PoolAllocate AssistDS include $(LEVEL)/Makefile.common Propchange: poolalloc/trunk/lib/PoolAllocate/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Thu Feb 18 18:12:39 2010 @@ -0,0 +1 @@ +.dep.inc Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=96632&r1=96631&r2=96632&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Thu Feb 18 18:12:39 2010 @@ -48,13 +48,6 @@ cl::opt PA::PA_SAFECODE("pa-safecode", cl::ReallyHidden); -#if 0 -#define TIME_REGION(VARNAME, DESC) \ - NamedRegionTimer VARNAME(DESC) -#else -#define TIME_REGION(VARNAME, DESC) -#endif - namespace { RegisterPass X("poolalloc", "Pool allocate disjoint data structures"); @@ -151,7 +144,6 @@ // program, don't traverse newly added ones. If the function needs new // arguments, make its clone. std::set ClonedFunctions; -{TIME_REGION(X, "MakeFunctionClone"); for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isDeclaration() && !ClonedFunctions.count(I) && Graphs->hasDSGraph(*I)) @@ -159,18 +151,15 @@ FuncMap[I] = Clone; ClonedFunctions.insert(Clone); } -} // Now that all call targets are available, rewrite the function bodies of the // clones. -{TIME_REGION(X, "ProcessFunctionBody"); for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isDeclaration() && !ClonedFunctions.count(I) && Graphs->hasDSGraph(*I)) { std::map::iterator FI = FuncMap.find(I); ProcessFunctionBody(*I, FI != FuncMap.end() ? *FI->second : *I); } -} // // Replace any remaining uses of original functions with the transformed @@ -488,9 +477,7 @@ // Perform the cloning. std::vector Returns; -{TIME_REGION(X, "CloneFunctionInto"); CloneFunctionInto(New, &F, ValueMap, Returns); -} // // The CloneFunctionInto() function will copy the parameter attributes @@ -656,7 +643,6 @@ std::map &PoolDescriptors) { if (NodesToPA.empty()) return; - TIME_REGION(X, "CreatePools"); std::vector ResultPools; CurHeuristic->AssignToPools(NodesToPA, &F, NodesToPA[0]->getParentGraph(), Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=96632&r1=96631&r2=96632&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Thu Feb 18 18:12:39 2010 @@ -793,7 +793,7 @@ } } - std::string Name = TheCall->getName(); TheCall->setName(""); + std::string Name = TheCall->getName(); TheCall->setName(""); if (InvokeInst *II = dyn_cast(TheCall)) { NewCall = InvokeInst::Create (NewCallee, II->getNormalDest(), Modified: poolalloc/trunk/tools/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/tools/Makefile?rev=96632&r1=96631&r2=96632&view=diff ============================================================================== --- poolalloc/trunk/tools/Makefile (original) +++ poolalloc/trunk/tools/Makefile Thu Feb 18 18:12:39 2010 @@ -6,6 +6,6 @@ # # List all of the subdirectories that we will compile. # -PARALLEL_DIRS=Pa +PARALLEL_DIRS= #Pa include $(LEVEL)/Makefile.common From alenhar2 at cs.uiuc.edu Thu Feb 18 18:13:25 2010 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 19 Feb 2010 00:13:25 -0000 Subject: [llvm-commits] [poolalloc] r96633 - /poolalloc/trunk/include/rPA/ Message-ID: <201002190013.o1J0DPwP025476@zion.cs.uiuc.edu> Author: alenhar2 Date: Thu Feb 18 18:13:24 2010 New Revision: 96633 URL: http://llvm.org/viewvc/llvm-project?rev=96633&view=rev Log: clear out my old cruft (rDSA and rPA) Removed: poolalloc/trunk/include/rPA/ From grosbach at apple.com Thu Feb 18 18:16:24 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 19 Feb 2010 00:16:24 -0000 Subject: [llvm-commits] [llvm] r96634 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h lib/CodeGen/PrologEpilogInserter.cpp lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMBaseRegisterInfo.h Message-ID: <201002190016.o1J0GPtC025665@zion.cs.uiuc.edu> Author: grosbach Date: Thu Feb 18 18:16:24 2010 New Revision: 96634 URL: http://llvm.org/viewvc/llvm-project?rev=96634&view=rev Log: Radar 7636153. In the presence of large call frames, it's not sufficient for ARM to just check if a function has a FP to determine if it's safe to simplify the stack adjustment pseudo ops prior to eliminating frame indices. Allow targets to override the default behavior and does so for ARM and Thumb2. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=96634&r1=96633&r2=96634&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Thu Feb 18 18:16:24 2010 @@ -587,6 +587,17 @@ return !hasFP(MF); } + /// canSimplifyCallFramePseudos - When possible, it's best to simplify the + /// call frame pseudo ops before doing frame index elimination. This is + /// possible only when frame index references between the pseudos won't + /// need adjusted for the call frame adjustments. Normally, that's true + /// if the function has a reserved call frame or a frame pointer. Some + /// targets (Thumb2, for example) may have more complicated criteria, + /// however, and can override this behavior. + virtual bool canSimplifyCallFramePseudos(MachineFunction &MF) const { + return hasReservedCallFrame(MF) || hasFP(MF); + } + /// hasReservedSpillSlot - Return true if target has reserved a spill slot in /// the stack frame of the given function for the specified register. e.g. On /// x86, if the frame register is required, the first fixed stack object is Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=96634&r1=96633&r2=96634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Thu Feb 18 18:16:24 2010 @@ -175,9 +175,10 @@ MachineBasicBlock::iterator I = *i; // If call frames are not being included as part of the stack frame, and - // there is no dynamic allocation (therefore referencing frame slots off - // sp), leave the pseudo ops alone. We'll eliminate them later. - if (RegInfo->hasReservedCallFrame(Fn) || RegInfo->hasFP(Fn)) + // the target doesn't indicate otherwise, remove the call frame pseudos + // here. The sub/add sp instruction pairs are still inserted, but we don't + // need to track the SP adjustment for frame index elimination. + if (RegInfo->canSimplifyCallFramePseudos(Fn)) RegInfo->eliminateCallFramePseudoInstr(Fn, *I->getParent(), I); } } Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=96634&r1=96633&r2=96634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Thu Feb 18 18:16:24 2010 @@ -1085,6 +1085,16 @@ return !MF.getFrameInfo()->hasVarSizedObjects(); } +// canSimplifyCallFramePseudos - If there is a reserved call frame, the +// call frame pseudos can be simplified. Unlike most targets, having a FP +// is not sufficient here since we still may reference some objects via SP +// even when FP is available in Thumb2 mode. +bool ARMBaseRegisterInfo:: +canSimplifyCallFramePseudos(MachineFunction &MF) const { + ARMFunctionInfo *AFI = MF.getInfo(); + return hasReservedCallFrame(MF) || (AFI->isThumb1OnlyFunction() && hasFP(MF)); +} + static void emitSPUpdate(bool isARM, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, @@ -1149,7 +1159,6 @@ MachineInstr &MI = *II; MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); - const MachineFrameInfo *MFI = MF.getFrameInfo(); ARMFunctionInfo *AFI = MF.getInfo(); assert(!AFI->isThumb1OnlyFunction() && "This eliminateFrameIndex does not support Thumb1!"); @@ -1160,12 +1169,12 @@ } int FrameIndex = MI.getOperand(i).getIndex(); - int Offset = MFI->getObjectOffset(FrameIndex) + MFI->getStackSize() + SPAdj; unsigned FrameReg; - Offset = getFrameIndexReference(MF, FrameIndex, FrameReg); + int Offset = getFrameIndexReference(MF, FrameIndex, FrameReg); if (FrameReg != ARM::SP) SPAdj = 0; + Offset += SPAdj; // Modify MI as necessary to handle as much of 'Offset' as possible bool Done = false; Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=96634&r1=96633&r2=96634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Thu Feb 18 18:16:24 2010 @@ -138,6 +138,7 @@ virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const; virtual bool hasReservedCallFrame(MachineFunction &MF) const; + virtual bool canSimplifyCallFramePseudos(MachineFunction &MF) const; virtual void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, From sabre at nondot.org Thu Feb 18 18:27:40 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Feb 2010 00:27:40 -0000 Subject: [llvm-commits] [llvm] r96636 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002190027.o1J0RfpW026233@zion.cs.uiuc.edu> Author: lattner Date: Thu Feb 18 18:27:40 2010 New Revision: 96636 URL: http://llvm.org/viewvc/llvm-project?rev=96636&view=rev Log: introduce a new ResultVal and start keeping track of temporary values. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96636&r1=96635&r2=96636&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Thu Feb 18 18:27:40 2010 @@ -15,6 +15,46 @@ using namespace llvm; namespace { + /// ResultVal - When generating new nodes for the result of a pattern match, + /// this value is used to represent an input to the node. Result values can + /// either be an input that is 'recorded' in the RecordedNodes array by the + /// matcher or it can be a temporary value created by the emitter for things + /// like constants. + class ResultVal { + unsigned Number : 30; + enum { + Recorded, Temporary + } Kind : 2; // True if temporary, false if recorded. + public: + static ResultVal getRecorded(unsigned N) { + ResultVal R; + R.Number = N; + R.Kind = Recorded; + return R; + } + + static ResultVal getTemp(unsigned N) { + ResultVal R; + R.Number = N; + R.Kind = Temporary; + return R; + } + + bool isTemp() const { return Kind == Temporary; } + bool isRecorded() const { return Kind == Recorded; } + + unsigned getTempNo() const { + assert(isTemp()); + return Number; + } + + unsigned getRecordedNo() const { + assert(isRecorded()); + return Number; + } + }; + + class MatcherGen { const PatternToMatch &Pattern; const CodeGenDAGPatterns &CGP; @@ -28,8 +68,16 @@ /// number that they were captured as. These are biased by 1 to make /// insertion easier. StringMap VariableMap; + + /// NextRecordedOperandNo - As we emit opcodes to record matched values in + /// the RecordedNodes array, this keeps track of which slot will be next to + /// record into. unsigned NextRecordedOperandNo; + /// NextTemporary - As we generate code, this indicates the next temporary + /// ID that will be generated. + unsigned NextTemporary; + /// InputChains - This maintains the position in the recorded nodes array of /// all of the recorded input chains. SmallVector InputChains; @@ -64,18 +112,18 @@ // Result Code Generation. void EmitResultOperand(const TreePatternNode *N, - SmallVectorImpl &ResultOps); + SmallVectorImpl &ResultOps); void EmitResultLeafAsOperand(const TreePatternNode *N, - SmallVectorImpl &ResultOps); + SmallVectorImpl &ResultOps); void EmitResultInstructionAsOperand(const TreePatternNode *N, - SmallVectorImpl &ResultOps); + SmallVectorImpl &ResultOps); }; } // end anon namespace. MatcherGen::MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp) -: Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), +: Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), NextTemporary(0), Matcher(0), CurPredicate(0) { // We need to produce the matcher tree for the patterns source pattern. To do // this we need to match the structure as well as the types. To do the type @@ -396,12 +444,12 @@ //===----------------------------------------------------------------------===// void MatcherGen::EmitResultLeafAsOperand(const TreePatternNode *N, - SmallVectorImpl &ResultOps) { + SmallVectorImpl &ResultOps){ assert(N->isLeaf() && "Must be a leaf"); if (IntInit *II = dynamic_cast(N->getLeafValue())) { AddMatcherNode(new EmitIntegerMatcherNode(II->getValue(),N->getTypeNum(0))); - //ResultOps.push_back(TmpNode(TmpNo++)); + ResultOps.push_back(ResultVal::getTemp(NextTemporary++)); return; } @@ -410,13 +458,13 @@ if (DI->getDef()->isSubClassOf("Register")) { AddMatcherNode(new EmitRegisterMatcherNode(DI->getDef(), N->getTypeNum(0))); - //ResultOps.push_back(TmpNode(TmpNo++)); + ResultOps.push_back(ResultVal::getTemp(NextTemporary++)); return; } if (DI->getDef()->getName() == "zero_reg") { AddMatcherNode(new EmitRegisterMatcherNode(0, N->getTypeNum(0))); - //ResultOps.push_back(TmpNode(TmpNo++)); + ResultOps.push_back(ResultVal::getTemp(NextTemporary++)); return; } @@ -434,7 +482,7 @@ } void MatcherGen::EmitResultInstructionAsOperand(const TreePatternNode *N, - SmallVectorImpl &ResultOps) { + SmallVectorImpl &ResultOps){ Record *Op = N->getOperator(); const CodeGenTarget &CGT = CGP.getTargetInfo(); CodeGenInstruction &II = CGT.getInstruction(Op->getName()); @@ -456,7 +504,7 @@ // where there are predicate operands for an instruction, we need to fill // in the 'execute always' values. Match up the node operands to the // instruction operands to do this. - SmallVector Ops; + SmallVector Ops; for (unsigned ChildNo = 0, InstOpNo = NumResults, e = II.OperandList.size(); InstOpNo != e; ++InstOpNo) { @@ -489,7 +537,7 @@ } void MatcherGen::EmitResultOperand(const TreePatternNode *N, - SmallVectorImpl &ResultOps) { + SmallVectorImpl &ResultOps) { // This is something selected from the pattern we matched. if (!N->getName().empty()) { //errs() << "unhandled named node: \n"; @@ -514,7 +562,7 @@ // FIXME: Handle Ops. // FIXME: Ops should be vector of "ResultValue> which is either an index into // the results vector is is a temp result. - SmallVector Ops; + SmallVector Ops; EmitResultOperand(Pattern.getDstPattern(), Ops); //AddMatcherNode(new EmitNodeMatcherNode(Pattern)); } From asl at math.spbu.ru Thu Feb 18 18:29:36 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 19 Feb 2010 00:29:36 -0000 Subject: [llvm-commits] [llvm] r96637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h Message-ID: <201002190029.o1J0Ta6q026314@zion.cs.uiuc.edu> Author: asl Date: Thu Feb 18 18:29:36 2010 New Revision: 96637 URL: http://llvm.org/viewvc/llvm-project?rev=96637&view=rev Log: Use the same encoding for EH stuff uniformly on all MachO targets. This hopefulyl should unbreak EH on PPC/Darwin. Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=96637&r1=96636&r2=96637&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original) +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Thu Feb 18 18:29:36 2010 @@ -171,6 +171,11 @@ virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding) const; + + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; }; Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=96637&r1=96636&r2=96637&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Thu Feb 18 18:29:36 2010 @@ -33,6 +33,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; +using namespace dwarf; //===----------------------------------------------------------------------===// // ELF @@ -754,6 +755,22 @@ } +unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned TargetLoweringObjectFileMachO::getLSDAEncoding() const { + return DW_EH_PE_pcrel; +} + +unsigned TargetLoweringObjectFileMachO::getFDEEncoding() const { + return DW_EH_PE_pcrel; +} + +unsigned TargetLoweringObjectFileMachO::getTTypeEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + //===----------------------------------------------------------------------===// // COFF //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=96637&r1=96636&r2=96637&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Thu Feb 18 18:29:36 2010 @@ -148,35 +148,3 @@ return DW_EH_PE_absptr; } - -unsigned X8632_MachoTargetObjectFile::getPersonalityEncoding() const { - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; -} - -unsigned X8632_MachoTargetObjectFile::getLSDAEncoding() const { - return DW_EH_PE_pcrel; -} - -unsigned X8632_MachoTargetObjectFile::getFDEEncoding() const { - return DW_EH_PE_pcrel; -} - -unsigned X8632_MachoTargetObjectFile::getTTypeEncoding() const { - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; -} - -unsigned X8664_MachoTargetObjectFile::getPersonalityEncoding() const { - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; -} - -unsigned X8664_MachoTargetObjectFile::getLSDAEncoding() const { - return DW_EH_PE_pcrel; -} - -unsigned X8664_MachoTargetObjectFile::getFDEEncoding() const { - return DW_EH_PE_pcrel; -} - -unsigned X8664_MachoTargetObjectFile::getTTypeEncoding() const { - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; -} Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=96637&r1=96636&r2=96637&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Thu Feb 18 18:29:36 2010 @@ -25,10 +25,6 @@ virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding) const; - virtual unsigned getPersonalityEncoding() const; - virtual unsigned getLSDAEncoding() const; - virtual unsigned getFDEEncoding() const; - virtual unsigned getTTypeEncoding() const; }; /// X8664_MachoTargetObjectFile - This TLOF implementation is used for @@ -39,10 +35,6 @@ virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding) const; - virtual unsigned getPersonalityEncoding() const; - virtual unsigned getLSDAEncoding() const; - virtual unsigned getFDEEncoding() const; - virtual unsigned getTTypeEncoding() const; }; class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF { From sabre at nondot.org Thu Feb 18 18:33:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Feb 2010 00:33:13 -0000 Subject: [llvm-commits] [llvm] r96639 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <201002190033.o1J0XDtd026516@zion.cs.uiuc.edu> Author: lattner Date: Thu Feb 18 18:33:13 2010 New Revision: 96639 URL: http://llvm.org/viewvc/llvm-project?rev=96639&view=rev Log: I confused myself, temporaries will be recorded right along with other inputs. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=96639&r1=96638&r2=96639&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Thu Feb 18 18:33:13 2010 @@ -21,35 +21,15 @@ /// matcher or it can be a temporary value created by the emitter for things /// like constants. class ResultVal { - unsigned Number : 30; - enum { - Recorded, Temporary - } Kind : 2; // True if temporary, false if recorded. + unsigned Number; public: - static ResultVal getRecorded(unsigned N) { + static ResultVal get(unsigned N) { ResultVal R; R.Number = N; - R.Kind = Recorded; - return R; - } - - static ResultVal getTemp(unsigned N) { - ResultVal R; - R.Number = N; - R.Kind = Temporary; return R; } - bool isTemp() const { return Kind == Temporary; } - bool isRecorded() const { return Kind == Recorded; } - - unsigned getTempNo() const { - assert(isTemp()); - return Number; - } - - unsigned getRecordedNo() const { - assert(isRecorded()); + unsigned getNumber() const { return Number; } }; @@ -74,10 +54,6 @@ /// record into. unsigned NextRecordedOperandNo; - /// NextTemporary - As we generate code, this indicates the next temporary - /// ID that will be generated. - unsigned NextTemporary; - /// InputChains - This maintains the position in the recorded nodes array of /// all of the recorded input chains. SmallVector InputChains; @@ -123,7 +99,7 @@ MatcherGen::MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp) -: Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), NextTemporary(0), +: Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), Matcher(0), CurPredicate(0) { // We need to produce the matcher tree for the patterns source pattern. To do // this we need to match the structure as well as the types. To do the type @@ -449,7 +425,7 @@ if (IntInit *II = dynamic_cast(N->getLeafValue())) { AddMatcherNode(new EmitIntegerMatcherNode(II->getValue(),N->getTypeNum(0))); - ResultOps.push_back(ResultVal::getTemp(NextTemporary++)); + ResultOps.push_back(ResultVal::get(NextRecordedOperandNo++)); return; } @@ -458,13 +434,13 @@ if (DI->getDef()->isSubClassOf("Register")) { AddMatcherNode(new EmitRegisterMatcherNode(DI->getDef(), N->getTypeNum(0))); - ResultOps.push_back(ResultVal::getTemp(NextTemporary++)); + ResultOps.push_back(ResultVal::get(NextRecordedOperandNo++)); return; } if (DI->getDef()->getName() == "zero_reg") { AddMatcherNode(new EmitRegisterMatcherNode(0, N->getTypeNum(0))); - ResultOps.push_back(ResultVal::getTemp(NextTemporary++)); + ResultOps.push_back(ResultVal::get(NextRecordedOperandNo++)); return; } From evan.cheng at apple.com Thu Feb 18 18:34:39 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Feb 2010 00:34:39 -0000 Subject: [llvm-commits] [llvm] r96640 - in /llvm/trunk: lib/CodeGen/SelectionDAG/TargetLowering.cpp test/CodeGen/X86/xor-icmp.ll Message-ID: <201002190034.o1J0YeEY026580@zion.cs.uiuc.edu> Author: evancheng Date: Thu Feb 18 18:34:39 2010 New Revision: 96640 URL: http://llvm.org/viewvc/llvm-project?rev=96640&view=rev Log: Transform (xor (setcc), (setcc)) == / != 1 to (xor (setcc), (setcc)) != / == 1. e.g. On x86_64 %0 = icmp eq i32 %x, 0 %1 = icmp eq i32 %y, 0 %2 = xor i1 %1, %0 br i1 %2, label %bb, label %return => testl %edi, %edi sete %al testl %esi, %esi sete %cl cmpb %al, %cl je LBB1_2 Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/test/CodeGen/X86/xor-icmp.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=96640&r1=96639&r2=96640&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Thu Feb 18 18:34:39 2010 @@ -1855,9 +1855,19 @@ SDValue Op0 = N0; if (Op0.getOpcode() == ISD::TRUNCATE) Op0 = Op0.getOperand(0); - if (Op0.getOpcode() == ISD::AND && - isa(Op0.getOperand(1)) && - cast(Op0.getOperand(1))->getAPIntValue() == 1) { + + if ((Op0.getOpcode() == ISD::XOR || Op0.getOpcode() == ISD::AND) && + Op0.getOperand(0).getOpcode() == ISD::SETCC && + Op0.getOperand(1).getOpcode() == ISD::SETCC) { + // (and (setcc), (setcc)) == / != 1 -> (setcc) == / != (setcc) + // (xor (setcc), (setcc)) == / != 1 -> (setcc) != / == (setcc) + if (Op0.getOpcode() == ISD::XOR) + Cond = (Cond == ISD::SETEQ) ? ISD::SETNE : ISD::SETEQ; + return DAG.getSetCC(dl, VT, Op0.getOperand(0), Op0.getOperand(1), + Cond); + } else if (Op0.getOpcode() == ISD::AND && + isa(Op0.getOperand(1)) && + cast(Op0.getOperand(1))->getAPIntValue() == 1) { if (Op0.getValueType() != VT) Op0 = DAG.getNode(ISD::AND, dl, VT, DAG.getNode(ISD::TRUNCATE, dl, VT, Op0.getOperand(0)), Modified: llvm/trunk/test/CodeGen/X86/xor-icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xor-icmp.ll?rev=96640&r1=96639&r2=96640&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/xor-icmp.ll (original) +++ llvm/trunk/test/CodeGen/X86/xor-icmp.ll Thu Feb 18 18:34:39 2010 @@ -1,5 +1,6 @@ ; RUN: llc < %s -march=x86 | FileCheck %s -check-prefix=X32 ; RUN: llc < %s -march=x86-64 | FileCheck %s -check-prefix=X64 +; rdar://7367229 define i32 @t(i32 %a, i32 %b) nounwind ssp { entry: @@ -34,3 +35,33 @@ declare i32 @foo(...) declare i32 @bar(...) + +define i32 @t2(i32 %x, i32 %y) nounwind ssp { +; X32: t2: +; X32: cmpl +; X32: sete +; X32: cmpl +; X32: sete +; X32-NOT: xor +; X32: je + +; X64: t2: +; X64: testl +; X64: sete +; X64: testl +; X64: sete +; X64-NOT: xor +; X64: je +entry: + %0 = icmp eq i32 %x, 0 ; [#uses=1] + %1 = icmp eq i32 %y, 0 ; [#uses=1] + %2 = xor i1 %1, %0 ; [#uses=1] + br i1 %2, label %bb, label %return + +bb: ; preds = %entry + %3 = tail call i32 (...)* @foo() nounwind ; [#uses=0] + ret i32 undef + +return: ; preds = %entry + ret i32 undef +} From dalej at apple.com Thu Feb 18 19:54:37 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 19 Feb 2010 01:54:37 -0000 Subject: [llvm-commits] [llvm] r96653 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <201002190154.o1J1sc1E030684@zion.cs.uiuc.edu> Author: johannes Date: Thu Feb 18 19:54:37 2010 New Revision: 96653 URL: http://llvm.org/viewvc/llvm-project?rev=96653&view=rev Log: Revert 96626, which causes build failure on ppc Darwin. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=96653&r1=96652&r2=96653&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Thu Feb 18 19:54:37 2010 @@ -586,11 +586,6 @@ /// compute a trip count, or if the loop is deleted. void forgetLoop(const Loop *L); - /// forgetValue - This method should be called by the client when it has - /// changed a value in a way that may effect its value, or which may - /// disconnect it from a def-use chain linking it to a loop. - void forgetValue(Value *V); - /// GetMinTrailingZeros - Determine the minimum number of zero bits that S /// is guaranteed to end in (at every loop iteration). It is, at the same /// time, the minimum number of times S is divisible by 2. For example, Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96653&r1=96652&r2=96653&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Feb 18 19:54:37 2010 @@ -3485,35 +3485,6 @@ } } -/// forgetValue - This method should be called by the client when it has -/// changed a value in a way that may effect its value, or which may -/// disconnect it from a def-use chain linking it to a loop. -void ScalarEvolution::forgetValue(Value *V) { - Instruction *I = dyn_cast(V); - if (!I) return; - - // Drop information about expressions based on loop-header PHIs. - SmallVector Worklist; - Worklist.push_back(I); - - SmallPtrSet Visited; - while (!Worklist.empty()) { - I = Worklist.pop_back_val(); - if (!Visited.insert(I)) continue; - - std::map::iterator It = - Scalars.find(static_cast(I)); - if (It != Scalars.end()) { - ValuesAtScopes.erase(It->second); - Scalars.erase(It); - if (PHINode *PN = dyn_cast(I)) - ConstantEvolutionLoopExitValue.erase(PN); - } - - PushDefUseChildren(I, Worklist); - } -} - /// ComputeBackedgeTakenCount - Compute the number of times the backedge /// of the specified loop will execute. ScalarEvolution::BackedgeTakenInfo Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=96653&r1=96652&r2=96653&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Feb 18 19:54:37 2010 @@ -246,13 +246,6 @@ if (!PN->getType()->isIntegerTy() && !PN->getType()->isPointerTy()) continue; - // It's necessary to tell ScalarEvolution about this explicitly so that - // it can walk the def-use list and forget all SCEVs, as it may not be - // watching the PHI itself. Once the new exit value is in place, there - // may not be a def-use connection between the loop and every instruction - // which got a SCEVAddRecExpr for that loop. - SE->forgetValue(PN); - // Iterate over all of the values in all the PHI nodes. for (unsigned i = 0; i != NumPreds; ++i) { // If the value being merged in is not integer or is not defined From johnny.chen at apple.com Thu Feb 18 20:12:06 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Feb 2010 02:12:06 -0000 Subject: [llvm-commits] [llvm] r96654 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <201002190212.o1J2C6xP031600@zion.cs.uiuc.edu> Author: johnny Date: Thu Feb 18 20:12:06 2010 New Revision: 96654 URL: http://llvm.org/viewvc/llvm-project?rev=96654&view=rev Log: Added entries for ASR, LSL, LSR, ROR, and RRX so that the disassembler prints out the canonical form (A8.6.98) instead of the pseudo-instruction as provided via MOVs. DBG_ARM_DISASM=YES llvm-mc -triple=arm-unknown-unknown --disassemble 0xc0 0x00 0xa0 0xe1 Opcode=29 Name=ASR Format=ARM_FORMAT_LDMISCFRM 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- | 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 1: 0: 0| 0: 0: 0: 0| ------------------------------------------------------------------------------------------------- asr r0, r0, #1 Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96654&r1=96653&r2=96654&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Feb 18 20:12:06 2010 @@ -1278,6 +1278,30 @@ "mov", "\t$dst, $src, rrx", [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP; +//===----------------------------------------------------------------------===// +// Shift Instructions. +// +// These are for disassembly only. See also MOVs above. + +class AShI type> + : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src, am3offset:$offset), LdMiscFrm, + IIC_iMOVsr, opc, "\t$dst, $src, $offset", []>, UnaryDP { + let Inst{6-5} = type; + let Inst{25} = 0; +} + +def LSL : AShI<"lsl", 0b00>; +def LSR : AShI<"lsr", 0b01>; +def ASR : AShI<"asr", 0b10>; +def ROR : AShI<"ror", 0b11>; + +def RRX : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), LdMiscFrm, IIC_iMOVsr, + "rrx", "\t$dst, $src", []>, UnaryDP { + let Inst{25} = 0; + let Inst{11-7} = 0b00000; + let Inst{6-4} = 0b110; +} + // These aren't really mov instructions, but we have to define them this way // due to flag operands. From dpatel at apple.com Thu Feb 18 20:58:05 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 19 Feb 2010 02:58:05 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r96656 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <201002190258.o1J2w5wf001490@zion.cs.uiuc.edu> Author: dpatel Date: Thu Feb 18 20:58:05 2010 New Revision: 96656 URL: http://llvm.org/viewvc/llvm-project?rev=96656&view=rev Log: Fix debug info for vectors. Test is at test/FrontendC/2010-02-18-Dbg-VectorType.c Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=96656&r1=96655&r2=96656&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Feb 18 20:58:05 2010 @@ -735,15 +735,18 @@ DIType DebugInfo::createArrayType(tree type) { // type[n][m]...[p] - if (TYPE_STRING_FLAG(type) && TREE_CODE(TREE_TYPE(type)) == INTEGER_TYPE){ + if (TREE_CODE (type) == ARRAY_TYPE + && TYPE_STRING_FLAG(type) && TREE_CODE(TREE_TYPE(type)) == INTEGER_TYPE){ DEBUGASSERT(0 && "Don't support pascal strings"); return DIType(); } unsigned Tag = 0; - if (TREE_CODE(type) == VECTOR_TYPE) + if (TREE_CODE(type) == VECTOR_TYPE) { Tag = DW_TAG_vector_type; + type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type))); + } else Tag = DW_TAG_array_type; @@ -756,7 +759,8 @@ // type. tree atype = type; tree EltTy = TREE_TYPE(atype); - for (; TREE_CODE(atype) == ARRAY_TYPE; atype = TREE_TYPE(atype)) { + for (; TREE_CODE(atype) == ARRAY_TYPE; + atype = TREE_TYPE(atype)) { tree Domain = TYPE_DOMAIN(atype); if (Domain) { // FIXME - handle dynamic ranges From dpatel at apple.com Thu Feb 18 20:58:33 2010 From: dpatel at apple.com (Devang Patel) Date: Fri, 19 Feb 2010 02:58:33 -0000 Subject: [llvm-commits] [llvm] r96657 - /llvm/trunk/test/FrontendC/2010-02-18-Dbg-VectorType.c Message-ID: <201002190258.o1J2wXUp001519@zion.cs.uiuc.edu> Author: dpatel Date: Thu Feb 18 20:58:33 2010 New Revision: 96657 URL: http://llvm.org/viewvc/llvm-project?rev=96657&view=rev Log: Test case for r96656. Added: llvm/trunk/test/FrontendC/2010-02-18-Dbg-VectorType.c Added: llvm/trunk/test/FrontendC/2010-02-18-Dbg-VectorType.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-02-18-Dbg-VectorType.c?rev=96657&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2010-02-18-Dbg-VectorType.c (added) +++ llvm/trunk/test/FrontendC/2010-02-18-Dbg-VectorType.c Thu Feb 18 20:58:33 2010 @@ -0,0 +1,9 @@ +// RUN: %llvmgcc -S -O0 -g %s -o - | grep DW_TAG_typedef | grep float4 +typedef float float4 __attribute__((vector_size(16))); + +int main(){ + volatile float4 x = (float4) { 0.0f, 1.0f, 2.0f, 3.0f }; + x += x; + return 0; +} + From clattner at apple.com Fri Feb 19 00:06:34 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Feb 2010 22:06:34 -0800 Subject: [llvm-commits] [llvm] r96654 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td In-Reply-To: <201002190212.o1J2C6xP031600@zion.cs.uiuc.edu> References: <201002190212.o1J2C6xP031600@zion.cs.uiuc.edu> Message-ID: <40314429-21D4-4D4D-BDFB-747EAC0EF6A2@apple.com> On Feb 18, 2010, at 6:12 PM, Johnny Chen wrote: > Author: johnny > Date: Thu Feb 18 20:12:06 2010 > New Revision: 96654 > > URL: http://llvm.org/viewvc/llvm-project?rev=96654&view=rev > Log: > Added entries for ASR, LSL, LSR, ROR, and RRX so that the disassembler prints > out the canonical form (A8.6.98) instead of the pseudo-instruction as provided > via MOVs. Hi Johnny, Is this a case where this encoding turns into either a mov with asr operand (the canonical form) or into an asr pseudo op which prints better? If so, it would be better to handle this in the asmprinter than adding redundant encodings for this. You can see similar examples in the PPC backend. Please let me know if you need more pointers, -Chris > > DBG_ARM_DISASM=YES llvm-mc -triple=arm-unknown-unknown --disassemble > 0xc0 0x00 0xa0 0xe1 > Opcode=29 Name=ASR Format=ARM_FORMAT_LDMISCFRM > 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 > ------------------------------------------------------------------------------------------------- > | 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 1: 0: 0| 0: 0: 0: 0| > ------------------------------------------------------------------------------------------------- > > asr r0, r0, #1 > > Modified: > llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96654&r1=96653&r2=96654&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Feb 18 20:12:06 2010 > @@ -1278,6 +1278,30 @@ > "mov", "\t$dst, $src, rrx", > [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP; > > +//===----------------------------------------------------------------------===// > +// Shift Instructions. > +// > +// These are for disassembly only. See also MOVs above. > + > +class AShI type> > + : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src, am3offset:$offset), LdMiscFrm, > + IIC_iMOVsr, opc, "\t$dst, $src, $offset", []>, UnaryDP { > + let Inst{6-5} = type; > + let Inst{25} = 0; > +} > + > +def LSL : AShI<"lsl", 0b00>; > +def LSR : AShI<"lsr", 0b01>; > +def ASR : AShI<"asr", 0b10>; > +def ROR : AShI<"ror", 0b11>; > + > +def RRX : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), LdMiscFrm, IIC_iMOVsr, > + "rrx", "\t$dst, $src", []>, UnaryDP { > + let Inst{25} = 0; > + let Inst{11-7} = 0b00000; > + let Inst{6-4} = 0b110; > +} > + > // These aren't really mov instructions, but we have to define them this way > // due to flag operands. > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Fri Feb 19 01:02:21 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Feb 2010 07:02:21 -0000 Subject: [llvm-commits] [llvm] r96661 - /llvm/trunk/utils/TableGen/InstrEnumEmitter.cpp Message-ID: <201002190702.o1J72LHU011637@zion.cs.uiuc.edu> Author: lattner Date: Fri Feb 19 01:02:20 2010 New Revision: 96661 URL: http://llvm.org/viewvc/llvm-project?rev=96661&view=rev Log: fix this to work more determinstically, patch by Thomas Veith! Modified: llvm/trunk/utils/TableGen/InstrEnumEmitter.cpp Modified: llvm/trunk/utils/TableGen/InstrEnumEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrEnumEmitter.cpp?rev=96661&r1=96660&r2=96661&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/InstrEnumEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/InstrEnumEmitter.cpp Fri Feb 19 01:02:20 2010 @@ -29,7 +29,7 @@ std::string Namespace; for (CodeGenTarget::inst_iterator II = Target.inst_begin(), E = Target.inst_end(); II != E; ++II) { - if (II->second.Namespace != "TargetInstrInfo") { + if (II->second.Namespace != "TargetOpcode") { Namespace = II->second.Namespace; break; } From dalej at apple.com Fri Feb 19 01:14:22 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 19 Feb 2010 07:14:22 -0000 Subject: [llvm-commits] [llvm] r96662 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <201002190714.o1J7ENEb012121@zion.cs.uiuc.edu> Author: johannes Date: Fri Feb 19 01:14:22 2010 New Revision: 96662 URL: http://llvm.org/viewvc/llvm-project?rev=96662&view=rev Log: recommit 96626, evidence that it broke things appears to be spurious Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=96662&r1=96661&r2=96662&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Fri Feb 19 01:14:22 2010 @@ -586,6 +586,11 @@ /// compute a trip count, or if the loop is deleted. void forgetLoop(const Loop *L); + /// forgetValue - This method should be called by the client when it has + /// changed a value in a way that may effect its value, or which may + /// disconnect it from a def-use chain linking it to a loop. + void forgetValue(Value *V); + /// GetMinTrailingZeros - Determine the minimum number of zero bits that S /// is guaranteed to end in (at every loop iteration). It is, at the same /// time, the minimum number of times S is divisible by 2. For example, Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96662&r1=96661&r2=96662&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Feb 19 01:14:22 2010 @@ -3485,6 +3485,35 @@ } } +/// forgetValue - This method should be called by the client when it has +/// changed a value in a way that may effect its value, or which may +/// disconnect it from a def-use chain linking it to a loop. +void ScalarEvolution::forgetValue(Value *V) { + Instruction *I = dyn_cast(V); + if (!I) return; + + // Drop information about expressions based on loop-header PHIs. + SmallVector Worklist; + Worklist.push_back(I); + + SmallPtrSet Visited; + while (!Worklist.empty()) { + I = Worklist.pop_back_val(); + if (!Visited.insert(I)) continue; + + std::map::iterator It = + Scalars.find(static_cast(I)); + if (It != Scalars.end()) { + ValuesAtScopes.erase(It->second); + Scalars.erase(It); + if (PHINode *PN = dyn_cast(I)) + ConstantEvolutionLoopExitValue.erase(PN); + } + + PushDefUseChildren(I, Worklist); + } +} + /// ComputeBackedgeTakenCount - Compute the number of times the backedge /// of the specified loop will execute. ScalarEvolution::BackedgeTakenInfo Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=96662&r1=96661&r2=96662&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Fri Feb 19 01:14:22 2010 @@ -246,6 +246,13 @@ if (!PN->getType()->isIntegerTy() && !PN->getType()->isPointerTy()) continue; + // It's necessary to tell ScalarEvolution about this explicitly so that + // it can walk the def-use list and forget all SCEVs, as it may not be + // watching the PHI itself. Once the new exit value is in place, there + // may not be a def-use connection between the loop and every instruction + // which got a SCEVAddRecExpr for that loop. + SE->forgetValue(PN); + // Iterate over all of the values in all the PHI nodes. for (unsigned i = 0; i != NumPreds; ++i) { // If the value being merged in is not integer or is not defined From sabre at nondot.org Fri Feb 19 01:49:56 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Feb 2010 07:49:56 -0000 Subject: [llvm-commits] [llvm] r96663 - in /llvm/trunk: include/llvm/CodeGen/DAGISelHeader.h utils/TableGen/DAGISelMatcher.h utils/TableGen/DAGISelMatcherEmitter.cpp Message-ID: <201002190749.o1J7nu1F013581@zion.cs.uiuc.edu> Author: lattner Date: Fri Feb 19 01:49:56 2010 New Revision: 96663 URL: http://llvm.org/viewvc/llvm-project?rev=96663&view=rev Log: add emitter support for integer constants and simple physreg references. Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/utils/TableGen/DAGISelMatcher.h llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=96663&r1=96662&r2=96663&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Fri Feb 19 01:49:56 2010 @@ -172,6 +172,11 @@ return true; } +void EmitInteger(int64_t Val, MVT::SimpleValueType VT, + SmallVectorImpl &RecordedNodes) { + RecordedNodes.push_back(CurDAG->getTargetConstant(Val, VT)); +} + // These functions are marked always inline so that Idx doesn't get pinned to // the stack. ALWAYS_INLINE static int8_t @@ -218,7 +223,10 @@ OPC_CheckAndImm1, OPC_CheckAndImm2, OPC_CheckAndImm4, OPC_CheckAndImm8, OPC_CheckOrImm1, OPC_CheckOrImm2, OPC_CheckOrImm4, OPC_CheckOrImm8, OPC_CheckFoldableChainNode, - OPC_CheckChainCompatible + OPC_CheckChainCompatible, + + OPC_EmitInteger1, OPC_EmitInteger2, OPC_EmitInteger4, OPC_EmitInteger8, + OPC_EmitRegister }; struct MatchScope { @@ -417,6 +425,39 @@ break; continue; } + + case OPC_EmitRegister: { + unsigned RegNo = MatcherTable[MatcherIndex++]; + MVT::SimpleValueType VT = + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; + SDValue Reg = CurDAG->getRegister(RegNo, VT); + RecordedNodes.push_back(N); + continue; + } + case OPC_EmitInteger1: { + MVT::SimpleValueType VT = + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; + EmitInteger(GetInt1(MatcherTable, MatcherIndex), VT, RecordedNodes); + continue; + } + case OPC_EmitInteger2: { + MVT::SimpleValueType VT = + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; + EmitInteger(GetInt2(MatcherTable, MatcherIndex), VT, RecordedNodes); + continue; + } + case OPC_EmitInteger4: { + MVT::SimpleValueType VT = + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; + EmitInteger(GetInt4(MatcherTable, MatcherIndex), VT, RecordedNodes); + continue; + } + case OPC_EmitInteger8: { + MVT::SimpleValueType VT = + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; + EmitInteger(GetInt8(MatcherTable, MatcherIndex), VT, RecordedNodes); + continue; + } } // If the code reached this point, then the match failed pop out to the next Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=96663&r1=96662&r2=96663&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Fri Feb 19 01:49:56 2010 @@ -386,7 +386,7 @@ EmitIntegerMatcherNode(int64_t val, MVT::SimpleValueType vt) : MatcherNode(EmitInteger), Val(val), VT(vt) {} - int64_t getVal() const { return Val; } + int64_t getValue() const { return Val; } MVT::SimpleValueType getVT() const { return VT; } static inline bool classof(const MatcherNode *N) { Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=96663&r1=96662&r2=96663&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Fri Feb 19 01:49:56 2010 @@ -213,10 +213,21 @@ << cast(N)->getPreviousOp() << ",\n"; return 2; - case MatcherNode::EmitInteger: + case MatcherNode::EmitInteger: { + int64_t Val = cast(N)->getValue(); + OS << "OPC_EmitInteger" << ClassifyInt(Val) << ", " + << getEnumName(cast(N)->getVT()) << ", "; + return EmitInt(Val, OS)+2; + } + case MatcherNode::EmitRegister: - // FIXME: Implement. - return 0; + OS << "OPC_EmitRegister, " + << getEnumName(cast(N)->getVT()) << ", "; + if (Record *R = cast(N)->getReg()) + OS << getQualifiedName(R) << ",\n"; + else + OS << "0 /*zero_reg*/,\n"; + return 3; } assert(0 && "Unreachable"); return 0; From baldrick at free.fr Fri Feb 19 03:18:54 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Feb 2010 09:18:54 -0000 Subject: [llvm-commits] [llvm] r96669 - /llvm/trunk/include/llvm/Type.h Message-ID: <201002190918.o1J9IsBG032341@zion.cs.uiuc.edu> Author: baldrick Date: Fri Feb 19 03:18:53 2010 New Revision: 96669 URL: http://llvm.org/viewvc/llvm-project?rev=96669&view=rev Log: Correct LastPrimitiveTyID: MetadataType is a primitive type. This change probably has no functional effect. Modified: llvm/trunk/include/llvm/Type.h Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=96669&r1=96668&r2=96669&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Fri Feb 19 03:18:53 2010 @@ -89,7 +89,7 @@ VectorTyID, ///< 15: SIMD 'packed' format, or other vector type NumTypeIDs, // Must remain as last defined ID - LastPrimitiveTyID = LabelTyID, + LastPrimitiveTyID = MetadataTyID, FirstDerivedTyID = IntegerTyID }; From baldrick at free.fr Fri Feb 19 05:30:41 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Feb 2010 11:30:41 -0000 Subject: [llvm-commits] [llvm] r96672 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/TargetLowering.cpp lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/critical-edge-split.ll test/CodeGen/X86/ins_subreg_coalesce-3.ll test/CodeGen/X86/trunc-to-bool.ll test/CodeGen/X86/xor-icmp.ll Message-ID: <201002191130.o1JBUgU4005844@zion.cs.uiuc.edu> Author: baldrick Date: Fri Feb 19 05:30:41 2010 New Revision: 96672 URL: http://llvm.org/viewvc/llvm-project?rev=96672&view=rev Log: Revert commits 96556 and 96640, because commit 96556 breaks the dragonegg self-host build. I reverted 96640 in order to revert 96556 (96640 goes on top of 96556), but it also looks like with both of them applied the breakage happens even earlier. The symptom of the 96556 miscompile is the following crash: llvm[3]: Compiling AlphaISelLowering.cpp for Release build cc1plus: /home/duncan/tmp/tmp/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:4982: void llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode*, llvm::SDNode*, llvm::SelectionDAG::DAGUpdateListener*): Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) == To->getValueType(i)) && "Cannot use this version of ReplaceAllUsesWith!"' failed. Stack dump: 0. Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN4llvm19AlphaTargetLowering14LowerOperationENS_7SDValueERNS_12SelectionDAGE' g++: Internal error: Aborted (program cc1plus) This occurs when building LLVM using LLVM built by LLVM (via dragonegg). Probably LLVM has miscompiled itself, though it may have miscompiled GCC and/or dragonegg itself: at this point of the self-host build, all of GCC, LLVM and dragonegg were built using LLVM. Unfortunately this kind of thing is extremely hard to debug, and while I did rummage around a bit I didn't find any smoking guns, aka obviously miscompiled code. Found by bisection. r96556 | evancheng | 2010-02-18 03:13:50 +0100 (Thu, 18 Feb 2010) | 5 lines Some dag combiner goodness: Transform br (xor (x, y)) -> br (x != y) Transform br (xor (xor (x,y), 1)) -> br (x == y) Also normalize (and (X, 1) == / != 1 -> (and (X, 1)) != / == 0 to match to "test on x86" and "tst on arm" r96640 | evancheng | 2010-02-19 01:34:39 +0100 (Fri, 19 Feb 2010) | 16 lines Transform (xor (setcc), (setcc)) == / != 1 to (xor (setcc), (setcc)) != / == 1. e.g. On x86_64 %0 = icmp eq i32 %x, 0 %1 = icmp eq i32 %y, 0 %2 = xor i1 %1, %0 br i1 %2, label %bb, label %return => testl %edi, %edi sete %al testl %esi, %esi sete %cl cmpb %al, %cl je LBB1_2 Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/critical-edge-split.ll llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll llvm/trunk/test/CodeGen/X86/xor-icmp.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=96672&r1=96671&r2=96672&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Feb 19 05:30:41 2010 @@ -4655,8 +4655,7 @@ DAG.DeleteNode(Trunc); } // Replace the uses of SRL with SETCC - WorkListRemover DeadNodes(*this); - DAG.ReplaceAllUsesOfValueWith(N1, SetCC, &DeadNodes); + DAG.ReplaceAllUsesOfValueWith(N1, SetCC); removeFromWorkList(N1.getNode()); DAG.DeleteNode(N1.getNode()); return SDValue(N, 0); // Return N so it doesn't get rechecked! @@ -4664,53 +4663,6 @@ } } } - - // Transform br(xor(x, y)) -> br(x != y) - // Transform br(xor(xor(x,y), 1)) -> br (x == y) - if (N1.hasOneUse() && N1.getOpcode() == ISD::XOR) { - SDNode *TheXor = N1.getNode(); - SDValue Op0 = TheXor->getOperand(0); - SDValue Op1 = TheXor->getOperand(1); - if (Op0.getOpcode() == Op1.getOpcode()) { - // Avoid missing important xor optimizations. - SDValue Tmp = visitXOR(TheXor); - if (Tmp.getNode()) { - DEBUG(dbgs() << "\nReplacing.8 "; - TheXor->dump(&DAG); - dbgs() << "\nWith: "; - Tmp.getNode()->dump(&DAG); - dbgs() << '\n'); - WorkListRemover DeadNodes(*this); - DAG.ReplaceAllUsesOfValueWith(N1, Tmp, &DeadNodes); - removeFromWorkList(TheXor); - DAG.DeleteNode(TheXor); - return DAG.getNode(ISD::BRCOND, N->getDebugLoc(), - MVT::Other, Chain, Tmp, N2); - } - } - - if (Op0.getOpcode() != ISD::SETCC && Op1.getOpcode() != ISD::SETCC) { - bool Equal = false; - if (ConstantSDNode *RHSCI = dyn_cast(Op0)) - if (RHSCI->getAPIntValue() == 1 && Op0.hasOneUse() && - Op0.getOpcode() == ISD::XOR) { - TheXor = Op0.getNode(); - Equal = true; - } - - SDValue SetCC = DAG.getSetCC(TheXor->getDebugLoc(), - TLI.getSetCCResultType(N1.getValueType()), - Op0, Op1, - Equal ? ISD::SETEQ : ISD::SETNE); - // Replace the uses of XOR with SETCC - WorkListRemover DeadNodes(*this); - DAG.ReplaceAllUsesOfValueWith(N1, SetCC, &DeadNodes); - removeFromWorkList(N1.getNode()); - DAG.DeleteNode(N1.getNode()); - return DAG.getNode(ISD::BRCOND, N->getDebugLoc(), - MVT::Other, Chain, SetCC, N2); - } - } return SDValue(); } @@ -5060,7 +5012,7 @@ assert(N->getValueType(2) == MVT::Other && "Malformed indexed loads?"); if (N->hasNUsesOfValue(0, 0) && N->hasNUsesOfValue(0, 1)) { SDValue Undef = DAG.getUNDEF(N->getValueType(0)); - DEBUG(dbgs() << "\nReplacing.7 "; + DEBUG(dbgs() << "\nReplacing.6 "; N->dump(&DAG); dbgs() << "\nWith: "; Undef.getNode()->dump(&DAG); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=96672&r1=96671&r2=96672&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Fri Feb 19 05:30:41 2010 @@ -1775,7 +1775,7 @@ break; // todo, be more careful with signed comparisons } } else if (N0.getOpcode() == ISD::SIGN_EXTEND_INREG && - (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { + (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { EVT ExtSrcTy = cast(N0.getOperand(1))->getVT(); unsigned ExtSrcTyBits = ExtSrcTy.getSizeInBits(); EVT ExtDstTy = N0.getValueType(); @@ -1809,6 +1809,7 @@ Cond); } else if ((N1C->isNullValue() || N1C->getAPIntValue() == 1) && (Cond == ISD::SETEQ || Cond == ISD::SETNE)) { + // SETCC (SETCC), [0|1], [EQ|NE] -> SETCC if (N0.getOpcode() == ISD::SETCC) { bool TrueWhenTrue = (Cond == ISD::SETEQ) ^ (N1C->getAPIntValue() != 1); @@ -1821,9 +1822,9 @@ N0.getOperand(0).getValueType().isInteger()); return DAG.getSetCC(dl, VT, N0.getOperand(0), N0.getOperand(1), CC); } - + if ((N0.getOpcode() == ISD::XOR || - (N0.getOpcode() == ISD::AND && + (N0.getOpcode() == ISD::AND && N0.getOperand(0).getOpcode() == ISD::XOR && N0.getOperand(1) == N0.getOperand(0).getOperand(1))) && isa(N0.getOperand(1)) && @@ -1846,36 +1847,9 @@ N0.getOperand(0).getOperand(0), N0.getOperand(1)); } - return DAG.getSetCC(dl, VT, Val, N1, Cond == ISD::SETEQ ? ISD::SETNE : ISD::SETEQ); } - } else if (N1C->getAPIntValue() == 1) { - // If this is (X&1) == / != 1, normalize it to (X&1) != / == 0. - SDValue Op0 = N0; - if (Op0.getOpcode() == ISD::TRUNCATE) - Op0 = Op0.getOperand(0); - - if ((Op0.getOpcode() == ISD::XOR || Op0.getOpcode() == ISD::AND) && - Op0.getOperand(0).getOpcode() == ISD::SETCC && - Op0.getOperand(1).getOpcode() == ISD::SETCC) { - // (and (setcc), (setcc)) == / != 1 -> (setcc) == / != (setcc) - // (xor (setcc), (setcc)) == / != 1 -> (setcc) != / == (setcc) - if (Op0.getOpcode() == ISD::XOR) - Cond = (Cond == ISD::SETEQ) ? ISD::SETNE : ISD::SETEQ; - return DAG.getSetCC(dl, VT, Op0.getOperand(0), Op0.getOperand(1), - Cond); - } else if (Op0.getOpcode() == ISD::AND && - isa(Op0.getOperand(1)) && - cast(Op0.getOperand(1))->getAPIntValue() == 1) { - if (Op0.getValueType() != VT) - Op0 = DAG.getNode(ISD::AND, dl, VT, - DAG.getNode(ISD::TRUNCATE, dl, VT, Op0.getOperand(0)), - DAG.getConstant(1, VT)); - return DAG.getSetCC(dl, VT, Op0, - DAG.getConstant(0, Op0.getValueType()), - Cond == ISD::SETEQ ? ISD::SETNE : ISD::SETEQ); - } } } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=96672&r1=96671&r2=96672&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Feb 19 05:30:41 2010 @@ -5874,31 +5874,26 @@ /// LowerToBT - Result of 'and' is compared against zero. Turn it into a BT node /// if it's possible. -static SDValue LowerToBT(SDValue And, ISD::CondCode CC, +static SDValue LowerToBT(SDValue Op0, ISD::CondCode CC, DebugLoc dl, SelectionDAG &DAG) { - SDValue Op0 = And.getOperand(0); - SDValue Op1 = And.getOperand(1); - if (Op0.getOpcode() == ISD::TRUNCATE) - Op0 = Op0.getOperand(0); - if (Op1.getOpcode() == ISD::TRUNCATE) - Op1 = Op1.getOperand(0); - SDValue LHS, RHS; - if (Op1.getOpcode() == ISD::SHL) { - if (ConstantSDNode *And10C = dyn_cast(Op1.getOperand(0))) - if (And10C->getZExtValue() == 1) { - LHS = Op0; - RHS = Op1.getOperand(1); - } - } else if (Op0.getOpcode() == ISD::SHL) { - if (ConstantSDNode *And00C = dyn_cast(Op0.getOperand(0))) - if (And00C->getZExtValue() == 1) { - LHS = Op1; - RHS = Op0.getOperand(1); - } - } else if (Op1.getOpcode() == ISD::Constant) { - ConstantSDNode *AndRHS = cast(Op1); - SDValue AndLHS = Op0; + if (Op0.getOperand(1).getOpcode() == ISD::SHL) { + if (ConstantSDNode *Op010C = + dyn_cast(Op0.getOperand(1).getOperand(0))) + if (Op010C->getZExtValue() == 1) { + LHS = Op0.getOperand(0); + RHS = Op0.getOperand(1).getOperand(1); + } + } else if (Op0.getOperand(0).getOpcode() == ISD::SHL) { + if (ConstantSDNode *Op000C = + dyn_cast(Op0.getOperand(0).getOperand(0))) + if (Op000C->getZExtValue() == 1) { + LHS = Op0.getOperand(1); + RHS = Op0.getOperand(0).getOperand(1); + } + } else if (Op0.getOperand(1).getOpcode() == ISD::Constant) { + ConstantSDNode *AndRHS = cast(Op0.getOperand(1)); + SDValue AndLHS = Op0.getOperand(0); if (AndRHS->getZExtValue() == 1 && AndLHS.getOpcode() == ISD::SRL) { LHS = AndLHS.getOperand(0); RHS = AndLHS.getOperand(1); @@ -5948,17 +5943,6 @@ return NewSetCC; } - // Look for "(setcc) == / != 1" to avoid unncessary setcc. - if (Op0.getOpcode() == X86ISD::SETCC && - Op1.getOpcode() == ISD::Constant && - cast(Op1)->getZExtValue() == 1 && - (CC == ISD::SETEQ || CC == ISD::SETNE)) { - X86::CondCode CCode = (X86::CondCode)Op0.getConstantOperandVal(0); - CCode = X86::GetOppositeBranchCondition(CCode); - return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, - DAG.getConstant(CCode, MVT::i8), Op0.getOperand(1)); - } - bool isFP = Op.getOperand(1).getValueType().isFloatingPoint(); unsigned X86CC = TranslateX86CC(CC, isFP, Op0, Op1, DAG); if (X86CC == X86::COND_INVALID) Modified: llvm/trunk/test/CodeGen/X86/critical-edge-split.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/critical-edge-split.ll?rev=96672&r1=96671&r2=96672&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/critical-edge-split.ll (original) +++ llvm/trunk/test/CodeGen/X86/critical-edge-split.ll Fri Feb 19 05:30:41 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin -stats -info-output-file - | grep asm-printer | grep 29 +; RUN: llc < %s -mtriple=i386-apple-darwin -tailcallopt=false -stats -info-output-file - | grep asm-printer | grep 31 %CC = type { %Register } %II = type { %"struct.XX::II::$_74" } Modified: llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll?rev=96672&r1=96671&r2=96672&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/ins_subreg_coalesce-3.ll Fri Feb 19 05:30:41 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86-64 | grep mov | count 3 +; RUN: llc < %s -march=x86-64 | grep mov | count 5 %struct.COMPOSITE = type { i8, i16, i16 } %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 } Modified: llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll?rev=96672&r1=96671&r2=96672&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll (original) +++ llvm/trunk/test/CodeGen/X86/trunc-to-bool.ll Fri Feb 19 05:30:41 2010 @@ -3,14 +3,13 @@ ; value and as the operand of a branch. ; RUN: llc < %s -march=x86 | FileCheck %s -define i1 @test1(i32 %X) zeroext nounwind { +define i1 @test1(i32 %X) zeroext { %Y = trunc i32 %X to i1 ret i1 %Y } -; CHECK: test1: ; CHECK: andl $1, %eax -define i1 @test2(i32 %val, i32 %mask) nounwind { +define i1 @test2(i32 %val, i32 %mask) { entry: %shifted = ashr i32 %val, %mask %anded = and i32 %shifted, 1 @@ -21,10 +20,9 @@ ret_false: ret i1 false } -; CHECK: test2: -; CHECK: btl %eax +; CHECK: testb $1, %al -define i32 @test3(i8* %ptr) nounwind { +define i32 @test3(i8* %ptr) { %val = load i8* %ptr %tmp = trunc i8 %val to i1 br i1 %tmp, label %cond_true, label %cond_false @@ -33,10 +31,9 @@ cond_false: ret i32 42 } -; CHECK: test3: -; CHECK: testb $1, (%eax) +; CHECK: testb $1, %al -define i32 @test4(i8* %ptr) nounwind { +define i32 @test4(i8* %ptr) { %tmp = ptrtoint i8* %ptr to i1 br i1 %tmp, label %cond_true, label %cond_false cond_true: @@ -44,10 +41,9 @@ cond_false: ret i32 42 } -; CHECK: test4: -; CHECK: testb $1, 4(%esp) +; CHECK: testb $1, %al -define i32 @test5(double %d) nounwind { +define i32 @test6(double %d) { %tmp = fptosi double %d to i1 br i1 %tmp, label %cond_true, label %cond_false cond_true: @@ -55,5 +51,4 @@ cond_false: ret i32 42 } -; CHECK: test5: ; CHECK: testb $1 Modified: llvm/trunk/test/CodeGen/X86/xor-icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xor-icmp.ll?rev=96672&r1=96671&r2=96672&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/xor-icmp.ll (original) +++ llvm/trunk/test/CodeGen/X86/xor-icmp.ll Fri Feb 19 05:30:41 2010 @@ -1,6 +1,5 @@ ; RUN: llc < %s -march=x86 | FileCheck %s -check-prefix=X32 ; RUN: llc < %s -march=x86-64 | FileCheck %s -check-prefix=X64 -; rdar://7367229 define i32 @t(i32 %a, i32 %b) nounwind ssp { entry: @@ -35,33 +34,3 @@ declare i32 @foo(...) declare i32 @bar(...) - -define i32 @t2(i32 %x, i32 %y) nounwind ssp { -; X32: t2: -; X32: cmpl -; X32: sete -; X32: cmpl -; X32: sete -; X32-NOT: xor -; X32: je - -; X64: t2: -; X64: testl -; X64: sete -; X64: testl -; X64: sete -; X64-NOT: xor -; X64: je -entry: - %0 = icmp eq i32 %x, 0 ; [#uses=1] - %1 = icmp eq i32 %y, 0 ; [#uses=1] - %2 = xor i1 %1, %0 ; [#uses=1] - br i1 %2, label %bb, label %return - -bb: ; preds = %entry - %3 = tail call i32 (...)* @foo() nounwind ; [#uses=0] - ret i32 undef - -return: ; preds = %entry - ret i32 undef -} From baldrick at free.fr Fri Feb 19 08:14:39 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Feb 2010 14:14:39 -0000 Subject: [llvm-commits] [dragonegg] r96673 - /dragonegg/trunk/gcc-patches/i386_static.diff Message-ID: <201002191414.o1JEEdKW012001@zion.cs.uiuc.edu> Author: baldrick Date: Fri Feb 19 08:14:38 2010 New Revision: 96673 URL: http://llvm.org/viewvc/llvm-project?rev=96673&view=rev Log: Refresh patch. Modified: dragonegg/trunk/gcc-patches/i386_static.diff Modified: dragonegg/trunk/gcc-patches/i386_static.diff URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/gcc-patches/i386_static.diff?rev=96673&r1=96672&r2=96673&view=diff ============================================================================== --- dragonegg/trunk/gcc-patches/i386_static.diff (original) +++ dragonegg/trunk/gcc-patches/i386_static.diff Fri Feb 19 08:14:38 2010 @@ -1,7 +1,7 @@ Index: mainline/gcc/config/i386/i386.c =================================================================== ---- mainline.orig/gcc/config/i386/i386.c 2009-12-05 13:39:54.356912538 +0100 -+++ mainline/gcc/config/i386/i386.c 2009-12-05 13:44:12.786890585 +0100 +--- mainline.orig/gcc/config/i386/i386.c 2010-02-19 15:06:17.872956905 +0100 ++++ mainline/gcc/config/i386/i386.c 2010-02-19 15:13:17.162961421 +0100 @@ -4988,7 +4988,8 @@ case, we return the original mode and warn ABI change if CUM isn't NULL. */ @@ -23,7 +23,7 @@ classify_argument (enum machine_mode mode, const_tree type, enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset) { -@@ -5499,7 +5502,9 @@ +@@ -5500,7 +5503,9 @@ /* Examine the argument and return set number of register required in each class. Return 0 iff parameter should be passed in memory. */ @@ -34,7 +34,7 @@ examine_argument (enum machine_mode mode, const_tree type, int in_return, int *int_nregs, int *sse_nregs) { -@@ -6179,7 +6184,8 @@ +@@ -6182,7 +6187,8 @@ /* Return true when TYPE should be 128bit aligned for 32bit argument passing ABI. */ From criswell at uiuc.edu Fri Feb 19 08:39:13 2010 From: criswell at uiuc.edu (John Criswell) Date: Fri, 19 Feb 2010 14:39:13 -0000 Subject: [llvm-commits] [poolalloc] r96674 - in /poolalloc/trunk/lib/PoolAllocate: EntryPointAnalysis.cpp RunTimeAssociate.cpp Message-ID: <201002191439.o1JEdDD0013176@zion.cs.uiuc.edu> Author: criswell Date: Fri Feb 19 08:39:13 2010 New Revision: 96674 URL: http://llvm.org/viewvc/llvm-project?rev=96674&view=rev Log: Added newlines to the end of the files to fix a gcc compilation error on Maute. No functionality changes. Modified: poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp Modified: poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp?rev=96674&r1=96673&r2=96674&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/EntryPointAnalysis.cpp Fri Feb 19 08:39:13 2010 @@ -49,4 +49,5 @@ -} \ No newline at end of file +} + Modified: poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp?rev=96674&r1=96673&r2=96674&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp Fri Feb 19 08:39:13 2010 @@ -609,4 +609,5 @@ CallSite(NewCall).setCallingConv(CallSite(TheCall).getCallingConv()); TheCall->eraseFromParent(); -} \ No newline at end of file +} + From baldrick at free.fr Fri Feb 19 10:38:33 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Feb 2010 16:38:33 -0000 Subject: [llvm-commits] [dragonegg] r96678 - /dragonegg/trunk/llvm-backend.cpp Message-ID: <201002191638.o1JGcX6I019529@zion.cs.uiuc.edu> Author: baldrick Date: Fri Feb 19 10:38:32 2010 New Revision: 96678 URL: http://llvm.org/viewvc/llvm-project?rev=96678&view=rev Log: Fix thinko in covariant thunk emission logic. Modified: dragonegg/trunk/llvm-backend.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=96678&r1=96677&r2=96678&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Fri Feb 19 10:38:32 2010 @@ -1711,7 +1711,7 @@ RetVal = Builder.CreatePtrToInt(RetVal, IntPtrTy); Value *Offset = ConstantInt::get(IntPtrTy, node->thunk.fixed_offset); RetVal = Builder.CreateNSWAdd(RetVal, Offset); - RetVal = Builder.CreateIntToPtr(RetVal, Thunk->getType()); + RetVal = Builder.CreateIntToPtr(RetVal, Thunk->getReturnType()); } // Return the adjusted value. From bob.wilson at apple.com Fri Feb 19 11:11:00 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Feb 2010 17:11:00 -0000 Subject: [llvm-commits] [llvm] r96680 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h Message-ID: <201002191711.o1JHB03A021168@zion.cs.uiuc.edu> Author: bwilson Date: Fri Feb 19 11:10:59 2010 New Revision: 96680 URL: http://llvm.org/viewvc/llvm-project?rev=96680&view=rev Log: Revert Anton's most recent EH patch (r96637), since it breaks a lot of ARM and Thumb tests. Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=96680&r1=96679&r2=96680&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original) +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Fri Feb 19 11:10:59 2010 @@ -171,11 +171,6 @@ virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding) const; - - virtual unsigned getPersonalityEncoding() const; - virtual unsigned getLSDAEncoding() const; - virtual unsigned getFDEEncoding() const; - virtual unsigned getTTypeEncoding() const; }; Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=96680&r1=96679&r2=96680&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Fri Feb 19 11:10:59 2010 @@ -33,7 +33,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; -using namespace dwarf; //===----------------------------------------------------------------------===// // ELF @@ -755,22 +754,6 @@ } -unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const { - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; -} - -unsigned TargetLoweringObjectFileMachO::getLSDAEncoding() const { - return DW_EH_PE_pcrel; -} - -unsigned TargetLoweringObjectFileMachO::getFDEEncoding() const { - return DW_EH_PE_pcrel; -} - -unsigned TargetLoweringObjectFileMachO::getTTypeEncoding() const { - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; -} - //===----------------------------------------------------------------------===// // COFF //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=96680&r1=96679&r2=96680&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Fri Feb 19 11:10:59 2010 @@ -148,3 +148,35 @@ return DW_EH_PE_absptr; } + +unsigned X8632_MachoTargetObjectFile::getPersonalityEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8632_MachoTargetObjectFile::getLSDAEncoding() const { + return DW_EH_PE_pcrel; +} + +unsigned X8632_MachoTargetObjectFile::getFDEEncoding() const { + return DW_EH_PE_pcrel; +} + +unsigned X8632_MachoTargetObjectFile::getTTypeEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8664_MachoTargetObjectFile::getPersonalityEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} + +unsigned X8664_MachoTargetObjectFile::getLSDAEncoding() const { + return DW_EH_PE_pcrel; +} + +unsigned X8664_MachoTargetObjectFile::getFDEEncoding() const { + return DW_EH_PE_pcrel; +} + +unsigned X8664_MachoTargetObjectFile::getTTypeEncoding() const { + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; +} Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=96680&r1=96679&r2=96680&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Fri Feb 19 11:10:59 2010 @@ -25,6 +25,10 @@ virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding) const; + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; }; /// X8664_MachoTargetObjectFile - This TLOF implementation is used for @@ -35,6 +39,10 @@ virtual const MCExpr * getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding) const; + virtual unsigned getPersonalityEncoding() const; + virtual unsigned getLSDAEncoding() const; + virtual unsigned getFDEEncoding() const; + virtual unsigned getTTypeEncoding() const; }; class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF { From bob.wilson at apple.com Fri Feb 19 11:17:43 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Feb 2010 09:17:43 -0800 Subject: [llvm-commits] [llvm] r96637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h In-Reply-To: <201002190029.o1J0Ta6q026314@zion.cs.uiuc.edu> References: <201002190029.o1J0Ta6q026314@zion.cs.uiuc.edu> Message-ID: <252002AD-1166-49DB-9A01-1131298FECA9@apple.com> I've reverted this patch because it broke a lot of tests for our arm nightly testers. The assembler would not accept the llc output because of subtract expressions with undefined symbols. Here is a diff of the good and bad assembly produced for SingleSource/Regression/C++/EH/throw_rethrow_test: --- throw_rethrow_test.llc.s 2010-02-19 09:08:59.000000000 -0800 +++ throw_rethrow_test.llc.s.bad 2010-02-19 08:28:10.000000000 -0800 @@ -249,7 +249,7 @@ Lexception2: L_LSDA_2: .byte 255 - .byte 0 + .byte 155 .byte 34 .byte 3 .byte 8 @@ -281,8 +281,8 @@ .byte 3 .byte 125 - .long __ZTI3foo - .long __ZTIi + .long L__ZTI3foo$non_lazy_ptr-. + .long L__ZTIi$non_lazy_ptr-. .long 0x0 .byte 0 The "L__ZTI3foo$non_lazy_ptr" symbol is not defined. On Feb 18, 2010, at 4:29 PM, Anton Korobeynikov wrote: > Author: asl > Date: Thu Feb 18 18:29:36 2010 > New Revision: 96637 > > URL: http://llvm.org/viewvc/llvm-project?rev=96637&view=rev > Log: > Use the same encoding for EH stuff uniformly on all MachO targets. > This hopefulyl should unbreak EH on PPC/Darwin. > > Modified: > llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h > llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp > llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp > llvm/trunk/lib/Target/X86/X86TargetObjectFile.h > > Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=96637&r1=96636&r2=96637&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original) > +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Thu Feb 18 18:29:36 2010 > @@ -171,6 +171,11 @@ > virtual const MCExpr * > getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, > MachineModuleInfo *MMI, unsigned Encoding) const; > + > + virtual unsigned getPersonalityEncoding() const; > + virtual unsigned getLSDAEncoding() const; > + virtual unsigned getFDEEncoding() const; > + virtual unsigned getTTypeEncoding() const; > }; > > > > Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=96637&r1=96636&r2=96637&view=diff > > ============================================================================== > --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) > +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Thu Feb 18 18:29:36 2010 > @@ -33,6 +33,7 @@ > #include "llvm/ADT/SmallString.h" > #include "llvm/ADT/StringExtras.h" > using namespace llvm; > +using namespace dwarf; > > //===----------------------------------------------------------------------===// > // ELF > @@ -754,6 +755,22 @@ > } > > > +unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const { > + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; > +} > + > +unsigned TargetLoweringObjectFileMachO::getLSDAEncoding() const { > + return DW_EH_PE_pcrel; > +} > + > +unsigned TargetLoweringObjectFileMachO::getFDEEncoding() const { > + return DW_EH_PE_pcrel; > +} > + > +unsigned TargetLoweringObjectFileMachO::getTTypeEncoding() const { > + return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; > +} > + > //===----------------------------------------------------------------------===// > // COFF > //===----------------------------------------------------------------------===// > > Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=96637&r1=96636&r2=96637&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Thu Feb 18 18:29:36 2010 > @@ -148,35 +148,3 @@ > > return DW_EH_PE_absptr; > } > - > -unsigned X8632_MachoTargetObjectFile::getPersonalityEncoding() const { > - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; > -} > - > -unsigned X8632_MachoTargetObjectFile::getLSDAEncoding() const { > - return DW_EH_PE_pcrel; > -} > - > -unsigned X8632_MachoTargetObjectFile::getFDEEncoding() const { > - return DW_EH_PE_pcrel; > -} > - > -unsigned X8632_MachoTargetObjectFile::getTTypeEncoding() const { > - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; > -} > - > -unsigned X8664_MachoTargetObjectFile::getPersonalityEncoding() const { > - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; > -} > - > -unsigned X8664_MachoTargetObjectFile::getLSDAEncoding() const { > - return DW_EH_PE_pcrel; > -} > - > -unsigned X8664_MachoTargetObjectFile::getFDEEncoding() const { > - return DW_EH_PE_pcrel; > -} > - > -unsigned X8664_MachoTargetObjectFile::getTTypeEncoding() const { > - return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; > -} > > Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=96637&r1=96636&r2=96637&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) > +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Thu Feb 18 18:29:36 2010 > @@ -25,10 +25,6 @@ > virtual const MCExpr * > getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, > MachineModuleInfo *MMI, unsigned Encoding) const; > - virtual unsigned getPersonalityEncoding() const; > - virtual unsigned getLSDAEncoding() const; > - virtual unsigned getFDEEncoding() const; > - virtual unsigned getTTypeEncoding() const; > }; > > /// X8664_MachoTargetObjectFile - This TLOF implementation is used for > @@ -39,10 +35,6 @@ > virtual const MCExpr * > getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, > MachineModuleInfo *MMI, unsigned Encoding) const; > - virtual unsigned getPersonalityEncoding() const; > - virtual unsigned getLSDAEncoding() const; > - virtual unsigned getFDEEncoding() const; > - virtual unsigned getTTypeEncoding() const; > }; > > class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From anton at korobeynikov.info Fri Feb 19 11:18:30 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Fri, 19 Feb 2010 20:18:30 +0300 Subject: [llvm-commits] [llvm] r96680 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h In-Reply-To: <201002191711.o1JHB03A021168@zion.cs.uiuc.edu> References: <201002191711.o1JHB03A021168@zion.cs.uiuc.edu> Message-ID: Hi, Bob > Revert Anton's most recent EH patch (r96637), since it breaks a lot of > ARM and Thumb tests. Which ones, for example? I don't think we support dwarf eh on arm nowadays. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Fri Feb 19 11:20:52 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 19 Feb 2010 20:20:52 +0300 Subject: [llvm-commits] [llvm] r96637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h In-Reply-To: <252002AD-1166-49DB-9A01-1131298FECA9@apple.com> References: <201002190029.o1J0Ta6q026314@zion.cs.uiuc.edu> <252002AD-1166-49DB-9A01-1131298FECA9@apple.com> Message-ID: Hello, Bob > The "L__ZTI3foo$non_lazy_ptr" symbol is not defined. How are non-lazy stubs are generated on arm/darwin? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From bob.wilson at apple.com Fri Feb 19 11:28:55 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Feb 2010 09:28:55 -0800 Subject: [llvm-commits] [llvm] r96637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h In-Reply-To: References: <201002190029.o1J0Ta6q026314@zion.cs.uiuc.edu> <252002AD-1166-49DB-9A01-1131298FECA9@apple.com> Message-ID: I've never spent much time looking at how EH works in llvm, so I'm the wrong guy to ask about it. Hopefully someone else on the list knows something about it and will help figure it out. Otherwise, I'm not opposed to learning, but it would take me a while to get into it. On Feb 19, 2010, at 9:20 AM, Anton Korobeynikov wrote: > Hello, Bob > >> The "L__ZTI3foo$non_lazy_ptr" symbol is not defined. > How are non-lazy stubs are generated on arm/darwin? > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Fri Feb 19 11:39:32 2010 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 19 Feb 2010 20:39:32 +0300 Subject: [llvm-commits] [llvm] r96637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h In-Reply-To: References: <201002190029.o1J0Ta6q026314@zion.cs.uiuc.edu> <252002AD-1166-49DB-9A01-1131298FECA9@apple.com> Message-ID: Bob, > I've never spent much time looking at how EH works in llvm, so I'm the wrong guy to ask about it. This is not a EH-related thing actually. Another question - how one can test the patches wrt arm/darwin, if any? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From bob.wilson at apple.com Fri Feb 19 11:45:50 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Feb 2010 09:45:50 -0800 Subject: [llvm-commits] [llvm] r96637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h In-Reply-To: References: <201002190029.o1J0Ta6q026314@zion.cs.uiuc.edu> <252002AD-1166-49DB-9A01-1131298FECA9@apple.com> Message-ID: <59CD9192-28B0-4375-809B-DC2F66BAE214@apple.com> On Feb 19, 2010, at 9:39 AM, Anton Korobeynikov wrote: > Bob, > >> I've never spent much time looking at how EH works in llvm, so I'm the wrong guy to ask about it. > This is not a EH-related thing actually. Another question - how one > can test the patches wrt arm/darwin, if any? I'll send you the bitcode file for that throw_rethrow test, and I can test the assembly output if you want to mail it back to me. If you have changes that you think might affect arm/darwin, let me know and I'll see if I can help you test them out. From gohman at apple.com Fri Feb 19 12:12:07 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Feb 2010 18:12:07 -0000 Subject: [llvm-commits] [llvm] r96683 - in /llvm/trunk: lib/Analysis/ test/Analysis/ScalarEvolution/ test/Transforms/IndVarSimplify/ Message-ID: <201002191812.o1JIC7sL024239@zion.cs.uiuc.edu> Author: djg Date: Fri Feb 19 12:12:07 2010 New Revision: 96683 URL: http://llvm.org/viewvc/llvm-project?rev=96683&view=rev Log: Teach ScalarEvolution how to compute a tripcount for a loop with true or false as its exit condition. These are usually eliminated by SimplifyCFG, but the may be left around during a pass which wishes to preserve the CFG. Added: llvm/trunk/test/Analysis/ScalarEvolution/trip-count10.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/test/Transforms/IndVarSimplify/2003-09-12-MultiplePred.ll llvm/trunk/test/Transforms/IndVarSimplify/2003-12-10-RemoveInstrCrash.ll llvm/trunk/test/Transforms/IndVarSimplify/2003-12-15-Crash.ll llvm/trunk/test/Transforms/IndVarSimplify/2005-11-18-Crash.ll llvm/trunk/test/Transforms/IndVarSimplify/2006-12-10-BitCast.ll llvm/trunk/test/Transforms/IndVarSimplify/2009-05-24-useafterfree.ll llvm/trunk/test/Transforms/IndVarSimplify/avoid-i0.ll llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Feb 19 12:12:07 2010 @@ -3703,6 +3703,19 @@ if (ICmpInst *ExitCondICmp = dyn_cast(ExitCond)) return ComputeBackedgeTakenCountFromExitCondICmp(L, ExitCondICmp, TBB, FBB); + // Check for a constant condition. These are normally stripped out by + // SimplifyCFG, but ScalarEvolution may be used by a pass which wishes to + // preserve the CFG and is temporarily leaving constant conditions + // in place. + if (ConstantInt *CI = dyn_cast(ExitCond)) { + if (L->contains(FBB) == !CI->getZExtValue()) + // The backedge is always taken. + return getCouldNotCompute(); + else + // The backedge is never taken. + return getIntegerSCEV(0, CI->getType()); + } + // If it's not an integer or pointer comparison then compute it the hard way. return ComputeBackedgeTakenCountExhaustively(L, ExitCond, !L->contains(TBB)); } Added: llvm/trunk/test/Analysis/ScalarEvolution/trip-count10.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/trip-count10.ll?rev=96683&view=auto ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/trip-count10.ll (added) +++ llvm/trunk/test/Analysis/ScalarEvolution/trip-count10.ll Fri Feb 19 12:12:07 2010 @@ -0,0 +1,76 @@ +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +; Trip counts with trivial exit conditions. + +; CHECK: Determining loop execution counts for: @a +; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: Unpredictable max backedge-taken count. + +; CHECK: Determining loop execution counts for: @b +; CHECK: Loop %loop: backedge-taken count is false +; CHECK: Loop %loop: max backedge-taken count is false + +; CHECK: Determining loop execution counts for: @c +; CHECK: Loop %loop: backedge-taken count is false +; CHECK: Loop %loop: max backedge-taken count is false + +; CHECK: Determining loop execution counts for: @d +; CHECK: Loop %loop: Unpredictable backedge-taken count. +; CHECK: Loop %loop: Unpredictable max backedge-taken count. + +define void @a(i64 %n) nounwind { +entry: + %t0 = icmp sgt i64 %n, 0 + br i1 %t0, label %loop, label %return + +loop: + %i = phi i64 [ %i.next, %loop ], [ 0, %entry ] + %i.next = add nsw i64 %i, 1 + %exitcond = icmp eq i64 %i.next, %n + br i1 false, label %return, label %loop + +return: + ret void +} +define void @b(i64 %n) nounwind { +entry: + %t0 = icmp sgt i64 %n, 0 + br i1 %t0, label %loop, label %return + +loop: + %i = phi i64 [ %i.next, %loop ], [ 0, %entry ] + %i.next = add nsw i64 %i, 1 + %exitcond = icmp eq i64 %i.next, %n + br i1 true, label %return, label %loop + +return: + ret void +} +define void @c(i64 %n) nounwind { +entry: + %t0 = icmp sgt i64 %n, 0 + br i1 %t0, label %loop, label %return + +loop: + %i = phi i64 [ %i.next, %loop ], [ 0, %entry ] + %i.next = add nsw i64 %i, 1 + %exitcond = icmp eq i64 %i.next, %n + br i1 false, label %loop, label %return + +return: + ret void +} +define void @d(i64 %n) nounwind { +entry: + %t0 = icmp sgt i64 %n, 0 + br i1 %t0, label %loop, label %return + +loop: + %i = phi i64 [ %i.next, %loop ], [ 0, %entry ] + %i.next = add nsw i64 %i, 1 + %exitcond = icmp eq i64 %i.next, %n + br i1 true, label %loop, label %return + +return: + ret void +} Modified: llvm/trunk/test/Transforms/IndVarSimplify/2003-09-12-MultiplePred.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2003-09-12-MultiplePred.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2003-09-12-MultiplePred.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2003-09-12-MultiplePred.ll Fri Feb 19 12:12:07 2010 @@ -7,7 +7,7 @@ LoopHead: ; preds = %LoopHead, %0, %0 %A = phi i32 [ 7, %0 ], [ 7, %0 ], [ %B, %LoopHead ] ; [#uses=1] %B = add i32 %A, 1 ; [#uses=2] - br i1 false, label %LoopHead, label %Out + br i1 undef, label %LoopHead, label %Out Out: ; preds = %LoopHead ret i32 %B Modified: llvm/trunk/test/Transforms/IndVarSimplify/2003-12-10-RemoveInstrCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2003-12-10-RemoveInstrCrash.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2003-12-10-RemoveInstrCrash.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2003-12-10-RemoveInstrCrash.ll Fri Feb 19 12:12:07 2010 @@ -10,7 +10,7 @@ %k.0.pn = phi i32 [ %inc.4, %no_exit ], [ 1, %entry ] ; [#uses=1] %inc.3 = add i32 %j.0.pn, 1 ; [#uses=1] %inc.4 = add i32 %k.0.pn, 1 ; [#uses=1] - br i1 false, label %no_exit, label %loopexit + br i1 undef, label %no_exit, label %loopexit loopexit: ; preds = %no_exit, %entry ret void Modified: llvm/trunk/test/Transforms/IndVarSimplify/2003-12-15-Crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2003-12-15-Crash.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2003-12-15-Crash.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2003-12-15-Crash.ll Fri Feb 19 12:12:07 2010 @@ -8,7 +8,7 @@ loopexit.14: ; preds = %entry %tmp.738 = sub i32 0, 0 ; [#uses=1] - br i1 false, label %no_exit.15.preheader, label %loopexit.15 + br i1 undef, label %no_exit.15.preheader, label %loopexit.15 no_exit.15.preheader: ; preds = %loopexit.14 br label %no_exit.15 @@ -16,7 +16,7 @@ no_exit.15: ; preds = %no_exit.15, %no_exit.15.preheader %highC.0 = phi i32 [ %tmp.738, %no_exit.15.preheader ], [ %dec.0, %no_exit.15 ] ; [#uses=1] %dec.0 = add i32 %highC.0, -1 ; [#uses=1] - br i1 false, label %no_exit.15, label %loopexit.15 + br i1 undef, label %no_exit.15, label %loopexit.15 loopexit.15: ; preds = %no_exit.15, %loopexit.14 ret void Modified: llvm/trunk/test/Transforms/IndVarSimplify/2005-11-18-Crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2005-11-18-Crash.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2005-11-18-Crash.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2005-11-18-Crash.ll Fri Feb 19 12:12:07 2010 @@ -9,7 +9,7 @@ no_exit.0: ; preds = %no_exit.0, %entry %p.0.0 = phi i32* [ getelementptr ([29 x [29 x [2 x i32]]]* @fixtab, i32 0, i32 0, i32 0, i32 0), %entry ], [ %inc.0, %no_exit.0 ] ; [#uses=1] %inc.0 = getelementptr i32* %p.0.0, i32 1 ; [#uses=1] - br i1 false, label %no_exit.0, label %no_exit.1 + br i1 undef, label %no_exit.0, label %no_exit.1 no_exit.1: ; preds = %no_exit.0 ret void Modified: llvm/trunk/test/Transforms/IndVarSimplify/2006-12-10-BitCast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2006-12-10-BitCast.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2006-12-10-BitCast.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2006-12-10-BitCast.ll Fri Feb 19 12:12:07 2010 @@ -20,7 +20,7 @@ %tmp194.i53 = bitcast i32 %decay.i.0 to float ; [#uses=1] %tmp195.i = fsub float %tmp194.i53, 8.000000e+00 ; [#uses=1] %tmp195.i.upgrd.1 = bitcast float %tmp195.i to i32 ; [#uses=1] - br i1 false, label %cond_next182.i, label %bb418.i.preheader + br i1 undef, label %cond_next182.i, label %bb418.i.preheader bb418.i.preheader: ; preds = %cond_next182.i ret void Modified: llvm/trunk/test/Transforms/IndVarSimplify/2009-05-24-useafterfree.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2009-05-24-useafterfree.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2009-05-24-useafterfree.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2009-05-24-useafterfree.ll Fri Feb 19 12:12:07 2010 @@ -12,7 +12,7 @@ br label %bb.nph1 bb.nph1: ; preds = %.outer, %bb.nph1.preheader - br i1 false, label %bb.nph3.preheader, label %.outer + br i1 undef, label %bb.nph3.preheader, label %.outer bb.nph3.preheader: ; preds = %bb.nph1 br label %bb.nph3 @@ -31,7 +31,7 @@ br label %.outer .outer: ; preds = %.outer.loopexit, %bb.nph1 - br i1 false, label %bb.nph1, label %.outer._crit_edge.loopexit + br i1 undef, label %bb.nph1, label %.outer._crit_edge.loopexit .outer._crit_edge.loopexit: ; preds = %.outer br label %.outer._crit_edge Modified: llvm/trunk/test/Transforms/IndVarSimplify/avoid-i0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/avoid-i0.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/avoid-i0.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/avoid-i0.ll Fri Feb 19 12:12:07 2010 @@ -10,13 +10,13 @@ bb: ; preds = %bb6, %entry %p_71_addr.0 = phi i8 [ %p_71, %entry ], [ %0, %bb6 ] ; [#uses=0] - br i1 false, label %bb4, label %bb1 + br i1 undef, label %bb4, label %bb1 bb1: ; preds = %bb ret i32 0 bb4: ; preds = %bb4, %bb - br i1 false, label %bb6, label %bb4 + br i1 undef, label %bb6, label %bb4 bb6: ; preds = %bb4 %0 = and i8 0, 0 ; [#uses=1] Modified: llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll?rev=96683&r1=96682&r2=96683&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll Fri Feb 19 12:12:07 2010 @@ -16,7 +16,7 @@ %str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ] ; [#uses=1] %1 = getelementptr i8* %str2Ptr_addr.1, i64 1 ; [#uses=2] %2 = icmp ult i8* %1, %inLastBytePtr ; [#uses=0] - br i1 false, label %bb2, label %return + br i1 undef, label %bb2, label %return return: ; preds = %bb2 ret void @@ -32,7 +32,7 @@ %str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ] ; [#uses=1] %1 = getelementptr i8* %str2Ptr_addr.1, i64 1 ; [#uses=2] %2 = icmp slt i8* %1, %inLastBytePtr ; [#uses=0] - br i1 false, label %bb2, label %return + br i1 undef, label %bb2, label %return return: ; preds = %bb2 ret void From anton at korobeynikov.info Fri Feb 19 12:14:13 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Fri, 19 Feb 2010 21:14:13 +0300 Subject: [llvm-commits] [PATCH] Support the 'alignstack' attribute in the x86 backend In-Reply-To: <4B7C49B1.8060803@mymail.mines.edu> References: <4B7C394A.3010902@mymail.mines.edu> <4B7C49B1.8060803@mymail.mines.edu> Message-ID: Hello, Charles > The point of this is to FORCE the stack to be aligned to a certain > value, even if the ABI says the stack is aligned to some other value. >> 2. Are you sure that the maximum alignment you set won't be clobberred >> in the case when e.g. there will be vector spills? > I am now. Patch reattached with stronger test case. Looks good, please commit. Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From cdavis at mines.edu Fri Feb 19 12:17:13 2010 From: cdavis at mines.edu (Charles Davis) Date: Fri, 19 Feb 2010 18:17:13 -0000 Subject: [llvm-commits] [llvm] r96686 - in /llvm/trunk: lib/CodeGen/MachineFunction.cpp lib/Target/X86/X86RegisterInfo.cpp test/CodeGen/X86/stack-align.ll Message-ID: <201002191817.o1JIHDw7024493@zion.cs.uiuc.edu> Author: cdavis Date: Fri Feb 19 12:17:13 2010 New Revision: 96686 URL: http://llvm.org/viewvc/llvm-project?rev=96686&view=rev Log: Add support for the 'alignstack' attribute to the x86 backend. Fixes PR5254. Also, FileCheck'ize a test. Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/test/CodeGen/X86/stack-align.ll Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=96686&r1=96685&r2=96686&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Fri Feb 19 12:17:13 2010 @@ -95,6 +95,9 @@ MFInfo = 0; FrameInfo = new (Allocator.Allocate()) MachineFrameInfo(*TM.getFrameInfo()); + if (Fn->hasFnAttr(Attribute::StackAlignment)) + FrameInfo->setMaxAlignment(Attribute::getStackAlignmentFromAttrs( + Fn->getAttributes().getFnAttributes())); ConstantPool = new (Allocator.Allocate()) MachineConstantPool(TM.getTargetData()); Alignment = TM.getTargetLowering()->getFunctionAlignment(F); Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=96686&r1=96685&r2=96686&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Fri Feb 19 12:17:13 2010 @@ -446,8 +446,10 @@ bool X86RegisterInfo::needsStackRealignment(const MachineFunction &MF) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); + const Function *F = MF.getFunction(); bool requiresRealignment = - RealignStack && (MFI->getMaxAlignment() > StackAlign); + RealignStack && ((MFI->getMaxAlignment() > StackAlign) || + F->hasFnAttr(Attribute::StackAlignment)); // FIXME: Currently we don't support stack realignment for functions with // variable-sized allocas. Modified: llvm/trunk/test/CodeGen/X86/stack-align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-align.ll?rev=96686&r1=96685&r2=96686&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stack-align.ll (original) +++ llvm/trunk/test/CodeGen/X86/stack-align.ll Fri Feb 19 12:17:13 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -relocation-model=static -mcpu=yonah | grep {andpd.*4(%esp), %xmm} +; RUN: llc < %s -relocation-model=static -realign-stack=1 -mcpu=yonah | FileCheck %s ; The double argument is at 4(esp) which is 16-byte aligned, allowing us to ; fold the load into the andpd. @@ -12,6 +12,7 @@ %tmp = getelementptr { double, double }* %z, i32 0, i32 0 ; [#uses=1] %tmp1 = load double* %tmp, align 8 ; [#uses=1] %tmp2 = tail call double @fabs( double %tmp1 ) ; [#uses=1] + ; CHECK: andpd{{.*}}4(%esp), %xmm %tmp3 = load double* @G, align 16 ; [#uses=1] %tmp4 = tail call double @fabs( double %tmp3 ) ; [#uses=1] %tmp6 = fadd double %tmp4, %tmp2 ; [#uses=1] @@ -19,4 +20,20 @@ ret void } +define void @test2() alignstack(16) { +entry: + ; CHECK: andl{{.*}}$-16, %esp + ret void +} + +; Use a call to force a spill. +define <2 x double> @test3(<2 x double> %x, <2 x double> %y) alignstack(32) { +entry: + ; CHECK: andl{{.*}}$-32, %esp + call void @test2() + %A = mul <2 x double> %x, %y + ret <2 x double> %A +} + declare double @fabs(double) + From gohman at apple.com Fri Feb 19 12:49:22 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Feb 2010 18:49:22 -0000 Subject: [llvm-commits] [llvm] r96688 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <201002191849.o1JInN1O025859@zion.cs.uiuc.edu> Author: djg Date: Fri Feb 19 12:49:22 2010 New Revision: 96688 URL: http://llvm.org/viewvc/llvm-project?rev=96688&view=rev Log: Add a comment. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=96688&r1=96687&r2=96688&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Feb 19 12:49:22 2010 @@ -1973,6 +1973,12 @@ return getAddRecExpr(Operands, L, HasNUW, HasNSW); // {X,+,0} --> X } + // It's tempting to want to call getMaxBackedgeTakenCount count here and + // use that information to infer NUW and NSW flags. However, computing a + // BE count requires calling getAddRecExpr, so we may not yet have a + // meaningful BE count at this point (and if we don't, we'd be stuck + // with a SCEVCouldNotCompute as the cached BE count). + // If HasNSW is true and all the operands are non-negative, infer HasNUW. if (!HasNUW && HasNSW) { bool All = true; From bob.wilson at apple.com Fri Feb 19 12:59:54 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Feb 2010 18:59:54 -0000 Subject: [llvm-commits] [llvm] r96691 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h lib/CodeGen/PrologEpilogInserter.cpp lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMBaseRegisterInfo.h Message-ID: <201002191859.o1JIxsi5026530@zion.cs.uiuc.edu> Author: bwilson Date: Fri Feb 19 12:59:53 2010 New Revision: 96691 URL: http://llvm.org/viewvc/llvm-project?rev=96691&view=rev Log: Revert 96634. It causes assertion failures for 126.gcc and 176.gcc in the armv6 nightly tests. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=96691&r1=96690&r2=96691&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Fri Feb 19 12:59:53 2010 @@ -587,17 +587,6 @@ return !hasFP(MF); } - /// canSimplifyCallFramePseudos - When possible, it's best to simplify the - /// call frame pseudo ops before doing frame index elimination. This is - /// possible only when frame index references between the pseudos won't - /// need adjusted for the call frame adjustments. Normally, that's true - /// if the function has a reserved call frame or a frame pointer. Some - /// targets (Thumb2, for example) may have more complicated criteria, - /// however, and can override this behavior. - virtual bool canSimplifyCallFramePseudos(MachineFunction &MF) const { - return hasReservedCallFrame(MF) || hasFP(MF); - } - /// hasReservedSpillSlot - Return true if target has reserved a spill slot in /// the stack frame of the given function for the specified register. e.g. On /// x86, if the frame register is required, the first fixed stack object is Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=96691&r1=96690&r2=96691&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Fri Feb 19 12:59:53 2010 @@ -175,10 +175,9 @@ MachineBasicBlock::iterator I = *i; // If call frames are not being included as part of the stack frame, and - // the target doesn't indicate otherwise, remove the call frame pseudos - // here. The sub/add sp instruction pairs are still inserted, but we don't - // need to track the SP adjustment for frame index elimination. - if (RegInfo->canSimplifyCallFramePseudos(Fn)) + // there is no dynamic allocation (therefore referencing frame slots off + // sp), leave the pseudo ops alone. We'll eliminate them later. + if (RegInfo->hasReservedCallFrame(Fn) || RegInfo->hasFP(Fn)) RegInfo->eliminateCallFramePseudoInstr(Fn, *I->getParent(), I); } } Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=96691&r1=96690&r2=96691&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Fri Feb 19 12:59:53 2010 @@ -1085,16 +1085,6 @@ return !MF.getFrameInfo()->hasVarSizedObjects(); } -// canSimplifyCallFramePseudos - If there is a reserved call frame, the -// call frame pseudos can be simplified. Unlike most targets, having a FP -// is not sufficient here since we still may reference some objects via SP -// even when FP is available in Thumb2 mode. -bool ARMBaseRegisterInfo:: -canSimplifyCallFramePseudos(MachineFunction &MF) const { - ARMFunctionInfo *AFI = MF.getInfo(); - return hasReservedCallFrame(MF) || (AFI->isThumb1OnlyFunction() && hasFP(MF)); -} - static void emitSPUpdate(bool isARM, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, @@ -1159,6 +1149,7 @@ MachineInstr &MI = *II; MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); + const MachineFrameInfo *MFI = MF.getFrameInfo(); ARMFunctionInfo *AFI = MF.getInfo(); assert(!AFI->isThumb1OnlyFunction() && "This eliminateFrameIndex does not support Thumb1!"); @@ -1169,12 +1160,12 @@ } int FrameIndex = MI.getOperand(i).getIndex(); + int Offset = MFI->getObjectOffset(FrameIndex) + MFI->getStackSize() + SPAdj; unsigned FrameReg; - int Offset = getFrameIndexReference(MF, FrameIndex, FrameReg); + Offset = getFrameIndexReference(MF, FrameIndex, FrameReg); if (FrameReg != ARM::SP) SPAdj = 0; - Offset += SPAdj; // Modify MI as necessary to handle as much of 'Offset' as possible bool Done = false; Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=96691&r1=96690&r2=96691&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Fri Feb 19 12:59:53 2010 @@ -138,7 +138,6 @@ virtual bool requiresFrameIndexScavenging(const MachineFunction &MF) const; virtual bool hasReservedCallFrame(MachineFunction &MF) const; - virtual bool canSimplifyCallFramePseudos(MachineFunction &MF) const; virtual void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, From gohman at apple.com Fri Feb 19 13:32:50 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Feb 2010 19:32:50 -0000 Subject: [llvm-commits] [llvm] r96692 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/lsr-wrap.ll Message-ID: <201002191932.o1JJWo3D028273@zion.cs.uiuc.edu> Author: djg Date: Fri Feb 19 13:32:49 2010 New Revision: 96692 URL: http://llvm.org/viewvc/llvm-project?rev=96692&view=rev Log: Check for overflow when scaling up an add or an addrec for scaled reuse. Added: llvm/trunk/test/CodeGen/X86/lsr-wrap.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96692&r1=96691&r2=96692&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Feb 19 13:32:49 2010 @@ -337,6 +337,33 @@ print(errs()); errs() << '\n'; } +/// isAddRecSExtable - Return true if the given addrec can be sign-extended +/// without changing its value. +static bool isAddRecSExtable(const SCEVAddRecExpr *AR, ScalarEvolution &SE) { + const Type *WideTy = + IntegerType::get(SE.getContext(), + SE.getTypeSizeInBits(AR->getType()) + 1); + return isa(SE.getSignExtendExpr(AR, WideTy)); +} + +/// isAddSExtable - Return true if the given add can be sign-extended +/// without changing its value. +static bool isAddSExtable(const SCEVAddExpr *A, ScalarEvolution &SE) { + const Type *WideTy = + IntegerType::get(SE.getContext(), + SE.getTypeSizeInBits(A->getType()) + 1); + return isa(SE.getSignExtendExpr(A, WideTy)); +} + +/// isMulSExtable - Return true if the given add can be sign-extended +/// without changing its value. +static bool isMulSExtable(const SCEVMulExpr *A, ScalarEvolution &SE) { + const Type *WideTy = + IntegerType::get(SE.getContext(), + SE.getTypeSizeInBits(A->getType()) + 1); + return isa(SE.getSignExtendExpr(A, WideTy)); +} + /// getSDiv - Return an expression for LHS /s RHS, if it can be determined, /// or null otherwise. If IgnoreSignificantBits is true, expressions like /// (X * Y) /s Y are simplified to Y, ignoring that the multiplication may @@ -365,33 +392,37 @@ .sdiv(RC->getValue()->getValue())); } - // Distribute the sdiv over addrec operands. + // Distribute the sdiv over addrec operands, if the addrec doesn't overflow. if (const SCEVAddRecExpr *AR = dyn_cast(LHS)) { - const SCEV *Start = getSDiv(AR->getStart(), RHS, SE, - IgnoreSignificantBits); - if (!Start) return 0; - const SCEV *Step = getSDiv(AR->getStepRecurrence(SE), RHS, SE, - IgnoreSignificantBits); - if (!Step) return 0; - return SE.getAddRecExpr(Start, Step, AR->getLoop()); + if (IgnoreSignificantBits || isAddRecSExtable(AR, SE)) { + const SCEV *Start = getSDiv(AR->getStart(), RHS, SE, + IgnoreSignificantBits); + if (!Start) return 0; + const SCEV *Step = getSDiv(AR->getStepRecurrence(SE), RHS, SE, + IgnoreSignificantBits); + if (!Step) return 0; + return SE.getAddRecExpr(Start, Step, AR->getLoop()); + } } - // Distribute the sdiv over add operands. + // Distribute the sdiv over add operands, if the add doesn't overflow. if (const SCEVAddExpr *Add = dyn_cast(LHS)) { - SmallVector Ops; - for (SCEVAddExpr::op_iterator I = Add->op_begin(), E = Add->op_end(); - I != E; ++I) { - const SCEV *Op = getSDiv(*I, RHS, SE, - IgnoreSignificantBits); - if (!Op) return 0; - Ops.push_back(Op); + if (IgnoreSignificantBits || isAddSExtable(Add, SE)) { + SmallVector Ops; + for (SCEVAddExpr::op_iterator I = Add->op_begin(), E = Add->op_end(); + I != E; ++I) { + const SCEV *Op = getSDiv(*I, RHS, SE, + IgnoreSignificantBits); + if (!Op) return 0; + Ops.push_back(Op); + } + return SE.getAddExpr(Ops); } - return SE.getAddExpr(Ops); } // Check for a multiply operand that we can pull RHS out of. if (const SCEVMulExpr *Mul = dyn_cast(LHS)) - if (IgnoreSignificantBits || Mul->hasNoSignedWrap()) { + if (IgnoreSignificantBits || isMulSExtable(Mul, SE)) { SmallVector Ops; bool Found = false; for (SCEVMulExpr::op_iterator I = Mul->op_begin(), E = Mul->op_end(); Added: llvm/trunk/test/CodeGen/X86/lsr-wrap.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-wrap.ll?rev=96692&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-wrap.ll (added) +++ llvm/trunk/test/CodeGen/X86/lsr-wrap.ll Fri Feb 19 13:32:49 2010 @@ -0,0 +1,37 @@ +; RUN: llc -march=x86-64 < %s | FileCheck %s + +; LSR would like to use a single IV for both of these, however it's +; not safe due to wraparound. + +; CHECK: addb $-4, %r +; CHECK: decw % + + at g_19 = common global i32 0 ; [#uses=2] + +declare i32 @func_8(i8 zeroext) nounwind + +declare i32 @func_3(i8 signext) nounwind + +define void @func_1() nounwind { +entry: + br label %bb + +bb: ; preds = %bb, %entry + %indvar = phi i16 [ 0, %entry ], [ %indvar.next, %bb ] ; [#uses=2] + %tmp = sub i16 0, %indvar ; [#uses=1] + %tmp27 = trunc i16 %tmp to i8 ; [#uses=1] + %tmp1 = load i32* @g_19, align 4 ; [#uses=2] + %tmp2 = add i32 %tmp1, 1 ; [#uses=1] + store i32 %tmp2, i32* @g_19, align 4 + %tmp3 = trunc i32 %tmp1 to i8 ; [#uses=1] + %tmp4 = tail call i32 @func_8(i8 zeroext %tmp3) nounwind ; [#uses=0] + %tmp5 = shl i8 %tmp27, 2 ; [#uses=1] + %tmp6 = add i8 %tmp5, -112 ; [#uses=1] + %tmp7 = tail call i32 @func_3(i8 signext %tmp6) nounwind ; [#uses=0] + %indvar.next = add i16 %indvar, 1 ; [#uses=2] + %exitcond = icmp eq i16 %indvar.next, -28 ; [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb + ret void +} From johnny.chen at apple.com Fri Feb 19 13:33:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 19 Feb 2010 11:33:35 -0800 Subject: [llvm-commits] [llvm] r96654 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td In-Reply-To: <40314429-21D4-4D4D-BDFB-747EAC0EF6A2@apple.com> References: <201002190212.o1J2C6xP031600@zion.cs.uiuc.edu> <40314429-21D4-4D4D-BDFB-747EAC0EF6A2@apple.com> Message-ID: <13F69D8A-AC75-4D56-9FBC-91B72326B08C@apple.com> Hi Chris, These added encodings are are more specific than: def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm, IIC_iMOVsr, "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP { let Inst{25} = 0; } Relying on the decoder to decode a MOVs super-instruction would mean that it prints out: mov r0, r0, asr #1 which, according to A8.6.98, is a pseudo-instruction and is not the canonical form we want for disassembly (A8-199). And an added bonus is that MOVs cannot handle RRX (A8-282). Thanks. On Feb 18, 2010, at 10:06 PM, Chris Lattner wrote: > > On Feb 18, 2010, at 6:12 PM, Johnny Chen wrote: > >> Author: johnny >> Date: Thu Feb 18 20:12:06 2010 >> New Revision: 96654 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=96654&view=rev >> Log: >> Added entries for ASR, LSL, LSR, ROR, and RRX so that the disassembler prints >> out the canonical form (A8.6.98) instead of the pseudo-instruction as provided >> via MOVs. > > Hi Johnny, > > Is this a case where this encoding turns into either a mov with asr operand (the canonical form) or into an asr pseudo op which prints better? If so, it would be better to handle this in the asmprinter than adding redundant encodings for this. You can see similar examples in the PPC backend. Please let me know if you need more pointers, > > -Chris > > >> >> DBG_ARM_DISASM=YES llvm-mc -triple=arm-unknown-unknown --disassemble >> 0xc0 0x00 0xa0 0xe1 >> Opcode=29 Name=ASR Format=ARM_FORMAT_LDMISCFRM >> 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 >> ------------------------------------------------------------------------------------------------- >> | 1: 1: 1: 0| 0: 0: 0: 1| 1: 0: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 1: 0: 0| 0: 0: 0: 0| >> ------------------------------------------------------------------------------------------------- >> >> asr r0, r0, #1 >> >> Modified: >> llvm/trunk/lib/Target/ARM/ARMInstrInfo.td >> >> Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=96654&r1=96653&r2=96654&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) >> +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Feb 18 20:12:06 2010 >> @@ -1278,6 +1278,30 @@ >> "mov", "\t$dst, $src, rrx", >> [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP; >> >> +//===----------------------------------------------------------------------===// >> +// Shift Instructions. >> +// >> +// These are for disassembly only. See also MOVs above. >> + >> +class AShI type> >> + : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src, am3offset:$offset), LdMiscFrm, >> + IIC_iMOVsr, opc, "\t$dst, $src, $offset", []>, UnaryDP { >> + let Inst{6-5} = type; >> + let Inst{25} = 0; >> +} >> + >> +def LSL : AShI<"lsl", 0b00>; >> +def LSR : AShI<"lsr", 0b01>; >> +def ASR : AShI<"asr", 0b10>; >> +def ROR : AShI<"ror", 0b11>; >> + >> +def RRX : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), LdMiscFrm, IIC_iMOVsr, >> + "rrx", "\t$dst, $src", []>, UnaryDP { >> + let Inst{25} = 0; >> + let Inst{11-7} = 0b00000; >> + let Inst{6-4} = 0b110; >> +} >> + >> // These aren't really mov instructions, but we have to define them this way >> // due to flag operands. >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gohman at apple.com Fri Feb 19 13:35:48 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Feb 2010 19:35:48 -0000 Subject: [llvm-commits] [llvm] r96693 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <201002191935.o1JJZm6G028435@zion.cs.uiuc.edu> Author: djg Date: Fri Feb 19 13:35:48 2010 New Revision: 96693 URL: http://llvm.org/viewvc/llvm-project?rev=96693&view=rev Log: Rename getSDiv to getExactSDiv to reflect its behavior in cases where the division would have a remainder. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=96693&r1=96692&r2=96693&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Feb 19 13:35:48 2010 @@ -364,14 +364,15 @@ return isa(SE.getSignExtendExpr(A, WideTy)); } -/// getSDiv - Return an expression for LHS /s RHS, if it can be determined, -/// or null otherwise. If IgnoreSignificantBits is true, expressions like -/// (X * Y) /s Y are simplified to Y, ignoring that the multiplication may -/// overflow, which is useful when the result will be used in a context where -/// the most significant bits are ignored. -static const SCEV *getSDiv(const SCEV *LHS, const SCEV *RHS, - ScalarEvolution &SE, - bool IgnoreSignificantBits = false) { +/// getExactSDiv - Return an expression for LHS /s RHS, if it can be determined +/// and if the remainder is known to be zero, or null otherwise. If +/// IgnoreSignificantBits is true, expressions like (X * Y) /s Y are simplified +/// to Y, ignoring that the multiplication may overflow, which is useful when +/// the result will be used in a context where the most significant bits are +/// ignored. +static const SCEV *getExactSDiv(const SCEV *LHS, const SCEV *RHS, + ScalarEvolution &SE, + bool IgnoreSignificantBits = false) { // Handle the trivial case, which works for any SCEV type. if (LHS == RHS) return SE.getIntegerSCEV(1, LHS->getType()); @@ -395,11 +396,11 @@ // Distribute the sdiv over addrec operands, if the addrec doesn't overflow. if (const SCEVAddRecExpr *AR = dyn_cast(LHS)) { if (IgnoreSignificantBits || isAddRecSExtable(AR, SE)) { - const SCEV *Start = getSDiv(AR->getStart(), RHS, SE, - IgnoreSignificantBits); + const SCEV *Start = getExactSDiv(AR->getStart(), RHS, SE, + IgnoreSignificantBits); if (!Start) return 0; - const SCEV *Step = getSDiv(AR->getStepRecurrence(SE), RHS, SE, - IgnoreSignificantBits); + const SCEV *Step = getExactSDiv(AR->getStepRecurrence(SE), RHS, SE, + IgnoreSignificantBits); if (!Step) return 0; return SE.getAddRecExpr(Start, Step, AR->getLoop()); } @@ -411,8 +412,8 @@ SmallVector Ops; for (SCEVAddExpr::op_iterator I = Add->op_begin(), E = Add->op_end(); I != E; ++I) { - const SCEV *Op = getSDiv(*I, RHS, SE, - IgnoreSignificantBits); + const SCEV *Op = getExactSDiv(*I, RHS, SE, + IgnoreSignificantBits); if (!Op) return 0; Ops.push_back(Op); } @@ -428,7 +429,8 @@ for (SCEVMulExpr::op_iterator I = Mul->op_begin(), E = Mul->op_end(); I != E; ++I) { if (!Found) - if (const SCEV *Q = getSDiv(*I, RHS, SE, IgnoreSignificantBits)) { + if (const SCEV *Q = getExactSDiv(*I, RHS, SE, + IgnoreSignificantBits)) { Ops.push_back(Q); Found = true; continue; @@ -1560,7 +1562,7 @@ A = SE.getSignExtendExpr(A, B->getType()); } if (const SCEVConstant *D = - dyn_cast_or_null(getSDiv(B, A, SE))) { + dyn_cast_or_null(getExactSDiv(B, A, SE))) { // Stride of one or negative one can have reuse with non-addresses. if (D->getValue()->isOne() || D->getValue()->isAllOnesValue()) @@ -1754,13 +1756,13 @@ OldStride = SE.getSignExtendExpr(OldStride, NewStride->getType()); } if (const SCEVConstant *Factor = - dyn_cast_or_null(getSDiv(NewStride, OldStride, - SE, true))) { + dyn_cast_or_null(getExactSDiv(NewStride, OldStride, + SE, true))) { if (Factor->getValue()->getValue().getMinSignedBits() <= 64) Factors.insert(Factor->getValue()->getValue().getSExtValue()); } else if (const SCEVConstant *Factor = - dyn_cast_or_null(getSDiv(OldStride, NewStride, - SE, true))) { + dyn_cast_or_null(getExactSDiv(OldStride, NewStride, + SE, true))) { if (Factor->getValue()->getValue().getMinSignedBits() <= 64) Factors.insert(Factor->getValue()->getValue().getSExtValue()); } @@ -2175,14 +2177,14 @@ // Check that multiplying with each base register doesn't overflow. for (size_t i = 0, e = F.BaseRegs.size(); i != e; ++i) { F.BaseRegs[i] = SE.getMulExpr(F.BaseRegs[i], FactorS); - if (getSDiv(F.BaseRegs[i], FactorS, SE) != Base.BaseRegs[i]) + if (getExactSDiv(F.BaseRegs[i], FactorS, SE) != Base.BaseRegs[i]) goto next; } // Check that multiplying with the scaled register doesn't overflow. if (F.ScaledReg) { F.ScaledReg = SE.getMulExpr(F.ScaledReg, FactorS); - if (getSDiv(F.ScaledReg, FactorS, SE) != Base.ScaledReg) + if (getExactSDiv(F.ScaledReg, FactorS, SE) != Base.ScaledReg) continue; } @@ -2237,7 +2239,7 @@ continue; // Divide out the factor, ignoring high bits, since we'll be // scaling the value back up in the end. - if (const SCEV *Quotient = getSDiv(AR, FactorS, SE, true)) { + if (const SCEV *Quotient = getExactSDiv(AR, FactorS, SE, true)) { // TODO: This could be optimized to avoid all the copying. Formula F = Base; F.ScaledReg = Quotient; From alenhar2 at cs.uiuc.edu Fri Feb 19 13:44:45 2010 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 19 Feb 2010 19:44:45 -0000 Subject: [llvm-commits] [poolalloc] r96694 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <201002191944.o1JJijJp028884@zion.cs.uiuc.edu> Author: alenhar2 Date: Fri Feb 19 13:44:45 2010 New Revision: 96694 URL: http://llvm.org/viewvc/llvm-project?rev=96694&view=rev Log: extract value Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=96694&r1=96693&r2=96694&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Fri Feb 19 13:44:45 2010 @@ -413,8 +413,17 @@ } void GraphBuilder::visitExtractValueInst(ExtractValueInst& I) { - assert(0 && "Not supported yet"); - abort(); + DSNodeHandle Ptr = getValueDest(*I.getOperand(0)); + + // Make that the node is read from... + Ptr.getNode()->setReadMarker(); + + // Ensure a typerecord exists... + // FIXME: calculate offset + Ptr.getNode()->mergeTypeInfo(I.getType(), 0, false); + + if (isa(I.getType())) + setDestTo(I, getLink(Ptr)); } void GraphBuilder::visitGetElementPtrInst(User &GEP) { From evan.cheng at apple.com Fri Feb 19 13:57:35 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Feb 2010 11:57:35 -0800 Subject: [llvm-commits] [llvm] r96640 - in /llvm/trunk: lib/CodeGen/SelectionDAG/TargetLowering.cpp test/CodeGen/X86/xor-icmp.ll In-Reply-To: <201002190034.o1J0YeEY026580@zion.cs.uiuc.edu> References: <201002190034.o1J0YeEY026580@zion.cs.uiuc.edu> Message-ID: On Feb 18, 2010, at 4:34 PM, Evan Cheng wrote: > Author: evancheng > Date: Thu Feb 18 18:34:39 2010 > New Revision: 96640 > > URL: http://llvm.org/viewvc/llvm-project?rev=96640&view=rev > Log