Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: src/PNaClTranslator.cpp

Issue 877003003: Subzero: Use a "known" version of clang-format. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add a clang-format blacklist. Fix formatting "errors". Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTypes.cpp ('k') | src/assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the PNaCl bitcode file to Ice, to machine code 10 // This file implements the PNaCl bitcode file to Ice, to machine code
(...skipping 24 matching lines...) Expand all
35 namespace { 35 namespace {
36 using namespace llvm; 36 using namespace llvm;
37 37
38 // Models elements in the list of types defined in the types block. 38 // Models elements in the list of types defined in the types block.
39 // These elements can be undefined, a (simple) type, or a function type 39 // These elements can be undefined, a (simple) type, or a function type
40 // signature. Note that an extended type is undefined on construction. 40 // signature. Note that an extended type is undefined on construction.
41 // Use methods setAsSimpleType and setAsFuncSigType to define 41 // Use methods setAsSimpleType and setAsFuncSigType to define
42 // the extended type. 42 // the extended type.
43 class ExtendedType { 43 class ExtendedType {
44 ExtendedType &operator=(const ExtendedType &Ty) = delete; 44 ExtendedType &operator=(const ExtendedType &Ty) = delete;
45
45 public: 46 public:
46 /// Discriminator for LLVM-style RTTI. 47 /// Discriminator for LLVM-style RTTI.
47 enum TypeKind { Undefined, Simple, FuncSig }; 48 enum TypeKind { Undefined, Simple, FuncSig };
48 49
49 ExtendedType() : Kind(Undefined) {} 50 ExtendedType() : Kind(Undefined) {}
50 ExtendedType(const ExtendedType &Ty) = default; 51 ExtendedType(const ExtendedType &Ty) = default;
51 52
52 virtual ~ExtendedType() {} 53 virtual ~ExtendedType() {}
53 54
54 ExtendedType::TypeKind getKind() const { return Kind; } 55 ExtendedType::TypeKind getKind() const { return Kind; }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 Stream << "FuncSig"; 100 Stream << "FuncSig";
100 break; 101 break;
101 } 102 }
102 return Stream; 103 return Stream;
103 } 104 }
104 105
105 // Models an ICE type as an extended type. 106 // Models an ICE type as an extended type.
106 class SimpleExtendedType : public ExtendedType { 107 class SimpleExtendedType : public ExtendedType {
107 SimpleExtendedType(const SimpleExtendedType &) = delete; 108 SimpleExtendedType(const SimpleExtendedType &) = delete;
108 SimpleExtendedType &operator=(const SimpleExtendedType &) = delete; 109 SimpleExtendedType &operator=(const SimpleExtendedType &) = delete;
110
109 public: 111 public:
110 Ice::Type getType() const { return Signature.getReturnType(); } 112 Ice::Type getType() const { return Signature.getReturnType(); }
111 113
112 static bool classof(const ExtendedType *Ty) { 114 static bool classof(const ExtendedType *Ty) {
113 return Ty->getKind() == Simple; 115 return Ty->getKind() == Simple;
114 } 116 }
115 }; 117 };
116 118
117 // Models a function signature as an extended type. 119 // Models a function signature as an extended type.
118 class FuncSigExtendedType : public ExtendedType { 120 class FuncSigExtendedType : public ExtendedType {
119 FuncSigExtendedType(const FuncSigExtendedType &) = delete; 121 FuncSigExtendedType(const FuncSigExtendedType &) = delete;
120 FuncSigExtendedType &operator=(const FuncSigExtendedType &) = delete; 122 FuncSigExtendedType &operator=(const FuncSigExtendedType &) = delete;
123
121 public: 124 public:
122 const Ice::FuncSigType &getSignature() const { return Signature; } 125 const Ice::FuncSigType &getSignature() const { return Signature; }
123 void setReturnType(Ice::Type ReturnType) { 126 void setReturnType(Ice::Type ReturnType) {
124 Signature.setReturnType(ReturnType); 127 Signature.setReturnType(ReturnType);
125 } 128 }
126 void appendArgType(Ice::Type ArgType) { Signature.appendArgType(ArgType); } 129 void appendArgType(Ice::Type ArgType) { Signature.appendArgType(ArgType); }
127 static bool classof(const ExtendedType *Ty) { 130 static bool classof(const ExtendedType *Ty) {
128 return Ty->getKind() == FuncSig; 131 return Ty->getKind() == FuncSig;
129 } 132 }
130 }; 133 };
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 197
195 /// Returns the undefined type associated with type ID. 198 /// Returns the undefined type associated with type ID.
196 /// Note: Returns extended type ready to be defined. 199 /// Note: Returns extended type ready to be defined.
197 ExtendedType *getTypeByIDForDefining(unsigned ID) { 200 ExtendedType *getTypeByIDForDefining(unsigned ID) {
198 // Get corresponding element, verifying the value is still undefined 201 // Get corresponding element, verifying the value is still undefined
199 // (and hence allowed to be defined). 202 // (and hence allowed to be defined).
200 ExtendedType *Ty = getTypeByIDAsKind(ID, ExtendedType::Undefined); 203 ExtendedType *Ty = getTypeByIDAsKind(ID, ExtendedType::Undefined);
201 if (Ty) 204 if (Ty)
202 return Ty; 205 return Ty;
203 if (ID >= TypeIDValues.size()) 206 if (ID >= TypeIDValues.size())
204 TypeIDValues.resize(ID+1); 207 TypeIDValues.resize(ID + 1);
205 return &TypeIDValues[ID]; 208 return &TypeIDValues[ID];
206 } 209 }
207 210
208 /// Returns the type associated with the given index. 211 /// Returns the type associated with the given index.
209 Ice::Type getSimpleTypeByID(unsigned ID) { 212 Ice::Type getSimpleTypeByID(unsigned ID) {
210 const ExtendedType *Ty = getTypeByIDAsKind(ID, ExtendedType::Simple); 213 const ExtendedType *Ty = getTypeByIDAsKind(ID, ExtendedType::Simple);
211 if (Ty == nullptr) 214 if (Ty == nullptr)
212 // Return error recovery value. 215 // Return error recovery value.
213 return Ice::IceType_void; 216 return Ice::IceType_void;
214 return cast<SimpleExtendedType>(Ty)->getType(); 217 return cast<SimpleExtendedType>(Ty)->getType();
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 protected: 1002 protected:
1000 typedef SmallString<128> StringType; 1003 typedef SmallString<128> StringType;
1001 1004
1002 // Associates Name with the value defined by the given Index. 1005 // Associates Name with the value defined by the given Index.
1003 virtual void setValueName(uint64_t Index, StringType &Name) = 0; 1006 virtual void setValueName(uint64_t Index, StringType &Name) = 0;
1004 1007
1005 // Associates Name with the value defined by the given Index; 1008 // Associates Name with the value defined by the given Index;
1006 virtual void setBbName(uint64_t Index, StringType &Name) = 0; 1009 virtual void setBbName(uint64_t Index, StringType &Name) = 0;
1007 1010
1008 private: 1011 private:
1009
1010 void ProcessRecord() override; 1012 void ProcessRecord() override;
1011 1013
1012 void ConvertToString(StringType &ConvertedName) { 1014 void ConvertToString(StringType &ConvertedName) {
1013 const NaClBitcodeRecord::RecordVector &Values = Record.GetValues(); 1015 const NaClBitcodeRecord::RecordVector &Values = Record.GetValues();
1014 for (size_t i = 1, e = Values.size(); i != e; ++i) { 1016 for (size_t i = 1, e = Values.size(); i != e; ++i) {
1015 ConvertedName += static_cast<char>(Values[i]); 1017 ConvertedName += static_cast<char>(Values[i]);
1016 } 1018 }
1017 } 1019 }
1018 }; 1020 };
1019 1021
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 for (Ice::Type ArgType : Signature.getArgList()) { 1087 for (Ice::Type ArgType : Signature.getArgList()) {
1086 Func->addArg(getNextInstVar(ArgType)); 1088 Func->addArg(getNextInstVar(ArgType));
1087 } 1089 }
1088 } 1090 }
1089 } 1091 }
1090 1092
1091 ~FunctionParser() final {} 1093 ~FunctionParser() final {}
1092 1094
1093 const char *getBlockName() const override { return "function"; } 1095 const char *getBlockName() const override { return "function"; }
1094 1096
1095 Ice::Cfg *getFunc() const { 1097 Ice::Cfg *getFunc() const { return Func; }
1096 return Func;
1097 }
1098 1098
1099 uint32_t getNumGlobalIDs() const { 1099 uint32_t getNumGlobalIDs() const { return CachedNumGlobalValueIDs; }
1100 return CachedNumGlobalValueIDs;
1101 }
1102 1100
1103 void setNextLocalInstIndex(Ice::Operand *Op) { 1101 void setNextLocalInstIndex(Ice::Operand *Op) {
1104 setOperand(NextLocalInstIndex++, Op); 1102 setOperand(NextLocalInstIndex++, Op);
1105 } 1103 }
1106 1104
1107 // Set the next constant ID to the given constant C. 1105 // Set the next constant ID to the given constant C.
1108 void setNextConstantID(Ice::Constant *C) { setNextLocalInstIndex(C); } 1106 void setNextConstantID(Ice::Constant *C) { setNextLocalInstIndex(C); }
1109 1107
1110 // Returns the value referenced by the given value Index. 1108 // Returns the value referenced by the given value Index.
1111 Ice::Operand *getOperand(uint32_t Index) { 1109 Ice::Operand *getOperand(uint32_t Index) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 if (typeNumElements(Type1) != typeNumElements(Type2)) 1569 if (typeNumElements(Type1) != typeNumElements(Type2))
1572 return false; 1570 return false;
1573 Type1 = typeElementType(Type1); 1571 Type1 = typeElementType(Type1);
1574 Type2 = typeElementType(Type2); 1572 Type2 = typeElementType(Type2);
1575 return true; 1573 return true;
1576 } 1574 }
1577 1575
1578 /// Returns true iff an integer truncation from SourceType to TargetType is 1576 /// Returns true iff an integer truncation from SourceType to TargetType is
1579 /// valid. 1577 /// valid.
1580 static bool isIntTruncCastValid(Ice::Type SourceType, Ice::Type TargetType) { 1578 static bool isIntTruncCastValid(Ice::Type SourceType, Ice::Type TargetType) {
1581 return Ice::isIntegerType(SourceType) 1579 return Ice::isIntegerType(SourceType) && Ice::isIntegerType(TargetType) &&
1582 && Ice::isIntegerType(TargetType) 1580 simplifyOutCommonVectorType(SourceType, TargetType) &&
1583 && simplifyOutCommonVectorType(SourceType, TargetType) 1581 getScalarIntBitWidth(SourceType) > getScalarIntBitWidth(TargetType);
1584 && getScalarIntBitWidth(SourceType) > getScalarIntBitWidth(TargetType);
1585 } 1582 }
1586 1583
1587 /// Returns true iff a floating type truncation from SourceType to TargetType 1584 /// Returns true iff a floating type truncation from SourceType to TargetType
1588 /// is valid. 1585 /// is valid.
1589 static bool isFloatTruncCastValid(Ice::Type SourceType, 1586 static bool isFloatTruncCastValid(Ice::Type SourceType,
1590 Ice::Type TargetType) { 1587 Ice::Type TargetType) {
1591 return simplifyOutCommonVectorType(SourceType, TargetType) 1588 return simplifyOutCommonVectorType(SourceType, TargetType) &&
1592 && SourceType == Ice::IceType_f64 1589 SourceType == Ice::IceType_f64 && TargetType == Ice::IceType_f32;
1593 && TargetType == Ice::IceType_f32;
1594 } 1590 }
1595 1591
1596 /// Returns true iff an integer extension from SourceType to TargetType is 1592 /// Returns true iff an integer extension from SourceType to TargetType is
1597 /// valid. 1593 /// valid.
1598 static bool isIntExtCastValid(Ice::Type SourceType, Ice::Type TargetType) { 1594 static bool isIntExtCastValid(Ice::Type SourceType, Ice::Type TargetType) {
1599 return isIntTruncCastValid(TargetType, SourceType); 1595 return isIntTruncCastValid(TargetType, SourceType);
1600 } 1596 }
1601 1597
1602 /// Returns true iff a floating type extension from SourceType to TargetType 1598 /// Returns true iff a floating type extension from SourceType to TargetType
1603 /// is valid. 1599 /// is valid.
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 raw_string_ostream StrBuf(Buffer); 1985 raw_string_ostream StrBuf(Buffer);
1990 StrBuf << "Select condition type " << CondType 1986 StrBuf << "Select condition type " << CondType
1991 << " not allowed for values of type " << ThenType; 1987 << " not allowed for values of type " << ThenType;
1992 Error(StrBuf.str()); 1988 Error(StrBuf.str());
1993 appendErrorInstruction(ThenType); 1989 appendErrorInstruction(ThenType);
1994 return; 1990 return;
1995 } 1991 }
1996 } else if (CondVal->getType() != Ice::IceType_i1) { 1992 } else if (CondVal->getType() != Ice::IceType_i1) {
1997 std::string Buffer; 1993 std::string Buffer;
1998 raw_string_ostream StrBuf(Buffer); 1994 raw_string_ostream StrBuf(Buffer);
1999 StrBuf << "Select condition " << CondVal << " not type i1. Found: " 1995 StrBuf << "Select condition " << CondVal
2000 << CondVal->getType(); 1996 << " not type i1. Found: " << CondVal->getType();
2001 Error(StrBuf.str()); 1997 Error(StrBuf.str());
2002 appendErrorInstruction(ThenType); 1998 appendErrorInstruction(ThenType);
2003 return; 1999 return;
2004 } 2000 }
2005 CurrentNode->appendInst(Ice::InstSelect::create( 2001 CurrentNode->appendInst(Ice::InstSelect::create(
2006 Func, getNextInstVar(ThenType), CondVal, ThenVal, ElseVal)); 2002 Func, getNextInstVar(ThenType), CondVal, ThenVal, ElseVal));
2007 return; 2003 return;
2008 } 2004 }
2009 case naclbitc::FUNC_CODE_INST_EXTRACTELT: { 2005 case naclbitc::FUNC_CODE_INST_EXTRACTELT: {
2010 // EXTRACTELT: [opval, opval] 2006 // EXTRACTELT: [opval, opval]
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2072 assert(Op1 == nullptr && Op2 == nullptr); 2068 assert(Op1 == nullptr && Op2 == nullptr);
2073 setNextLocalInstIndex(nullptr); 2069 setNextLocalInstIndex(nullptr);
2074 return; 2070 return;
2075 } 2071 }
2076 Ice::Type Op1Type = Op1->getType(); 2072 Ice::Type Op1Type = Op1->getType();
2077 Ice::Type Op2Type = Op2->getType(); 2073 Ice::Type Op2Type = Op2->getType();
2078 Ice::Type DestType = getCompareResultType(Op1Type); 2074 Ice::Type DestType = getCompareResultType(Op1Type);
2079 if (Op1Type != Op2Type) { 2075 if (Op1Type != Op2Type) {
2080 std::string Buffer; 2076 std::string Buffer;
2081 raw_string_ostream StrBuf(Buffer); 2077 raw_string_ostream StrBuf(Buffer);
2082 StrBuf << "Compare argument types differ: " << Op1Type 2078 StrBuf << "Compare argument types differ: " << Op1Type << " and "
2083 << " and " << Op2Type; 2079 << Op2Type;
2084 Error(StrBuf.str()); 2080 Error(StrBuf.str());
2085 appendErrorInstruction(DestType); 2081 appendErrorInstruction(DestType);
2086 Op2 = Op1; 2082 Op2 = Op1;
2087 } 2083 }
2088 if (DestType == Ice::IceType_void) { 2084 if (DestType == Ice::IceType_void) {
2089 std::string Buffer; 2085 std::string Buffer;
2090 raw_string_ostream StrBuf(Buffer); 2086 raw_string_ostream StrBuf(Buffer);
2091 StrBuf << "Compare not defined for type " << Op1Type; 2087 StrBuf << "Compare not defined for type " << Op1Type;
2092 Error(StrBuf.str()); 2088 Error(StrBuf.str());
2093 return; 2089 return;
2094 } 2090 }
2095 Ice::Variable *Dest = getNextInstVar(DestType); 2091 Ice::Variable *Dest = getNextInstVar(DestType);
2096 if (isIntegerType(Op1Type)) { 2092 if (isIntegerType(Op1Type)) {
2097 Ice::InstIcmp::ICond Cond; 2093 Ice::InstIcmp::ICond Cond;
2098 if (!convertNaClBitcICmpOpToIce(Values[2], Cond)) { 2094 if (!convertNaClBitcICmpOpToIce(Values[2], Cond)) {
2099 std::string Buffer; 2095 std::string Buffer;
2100 raw_string_ostream StrBuf(Buffer); 2096 raw_string_ostream StrBuf(Buffer);
2101 StrBuf << "Compare record contains unknown integer predicate index: " 2097 StrBuf << "Compare record contains unknown integer predicate index: "
2102 << Values[2]; 2098 << Values[2];
2103 Error(StrBuf.str()); 2099 Error(StrBuf.str());
2104 appendErrorInstruction(DestType); 2100 appendErrorInstruction(DestType);
2105 } 2101 }
2106 CurrentNode->appendInst( 2102 CurrentNode->appendInst(
2107 Ice::InstIcmp::create(Func, Cond, Dest, Op1, Op2)); 2103 Ice::InstIcmp::create(Func, Cond, Dest, Op1, Op2));
2108 } else if (isFloatingType(Op1Type)){ 2104 } else if (isFloatingType(Op1Type)) {
2109 Ice::InstFcmp::FCond Cond; 2105 Ice::InstFcmp::FCond Cond;
2110 if (!convertNaClBitcFCompOpToIce(Values[2], Cond)) { 2106 if (!convertNaClBitcFCompOpToIce(Values[2], Cond)) {
2111 std::string Buffer; 2107 std::string Buffer;
2112 raw_string_ostream StrBuf(Buffer); 2108 raw_string_ostream StrBuf(Buffer);
2113 StrBuf << "Compare record contains unknown float predicate index: " 2109 StrBuf << "Compare record contains unknown float predicate index: "
2114 << Values[2]; 2110 << Values[2];
2115 Error(StrBuf.str()); 2111 Error(StrBuf.str());
2116 appendErrorInstruction(DestType); 2112 appendErrorInstruction(DestType);
2117 } 2113 }
2118 CurrentNode->appendInst( 2114 CurrentNode->appendInst(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 if (!isValidRecordSize(3, "branch")) 2157 if (!isValidRecordSize(3, "branch"))
2162 return; 2158 return;
2163 Ice::Operand *Cond = getRelativeOperand(Values[2], BaseIndex); 2159 Ice::Operand *Cond = getRelativeOperand(Values[2], BaseIndex);
2164 if (isIRGenerationDisabled()) { 2160 if (isIRGenerationDisabled()) {
2165 assert(Cond == nullptr); 2161 assert(Cond == nullptr);
2166 return; 2162 return;
2167 } 2163 }
2168 if (Cond->getType() != Ice::IceType_i1) { 2164 if (Cond->getType() != Ice::IceType_i1) {
2169 std::string Buffer; 2165 std::string Buffer;
2170 raw_string_ostream StrBuf(Buffer); 2166 raw_string_ostream StrBuf(Buffer);
2171 StrBuf << "Branch condition " << *Cond << " not i1. Found: " 2167 StrBuf << "Branch condition " << *Cond
2172 << Cond->getType(); 2168 << " not i1. Found: " << Cond->getType();
2173 Error(StrBuf.str()); 2169 Error(StrBuf.str());
2174 return; 2170 return;
2175 } 2171 }
2176 Ice::CfgNode *ThenBlock = getBranchBasicBlock(Values[0]); 2172 Ice::CfgNode *ThenBlock = getBranchBasicBlock(Values[0]);
2177 Ice::CfgNode *ElseBlock = getBranchBasicBlock(Values[1]); 2173 Ice::CfgNode *ElseBlock = getBranchBasicBlock(Values[1]);
2178 if (ThenBlock == nullptr || ElseBlock == nullptr) 2174 if (ThenBlock == nullptr || ElseBlock == nullptr)
2179 return; 2175 return;
2180 CurrentNode->appendInst( 2176 CurrentNode->appendInst(
2181 Ice::InstBr::create(Func, Cond, ThenBlock, ElseBlock)); 2177 Ice::InstBr::create(Func, Cond, ThenBlock, ElseBlock));
2182 } 2178 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 Ice::CfgNode *DefaultLabel = 2216 Ice::CfgNode *DefaultLabel =
2221 isIRGenDisabled ? nullptr : getBranchBasicBlock(Values[2]); 2217 isIRGenDisabled ? nullptr : getBranchBasicBlock(Values[2]);
2222 unsigned NumCases = Values[3]; 2218 unsigned NumCases = Values[3];
2223 2219
2224 // Now recognize each of the cases. 2220 // Now recognize each of the cases.
2225 if (!isValidRecordSize(4 + NumCases * 4, "switch")) 2221 if (!isValidRecordSize(4 + NumCases * 4, "switch"))
2226 return; 2222 return;
2227 Ice::InstSwitch *Switch = 2223 Ice::InstSwitch *Switch =
2228 isIRGenDisabled ? nullptr : Ice::InstSwitch::create(Func, NumCases, 2224 isIRGenDisabled ? nullptr : Ice::InstSwitch::create(Func, NumCases,
2229 Cond, DefaultLabel); 2225 Cond, DefaultLabel);
2230 unsigned ValCaseIndex = 4; // index to beginning of case entry. 2226 unsigned ValCaseIndex = 4; // index to beginning of case entry.
2231 for (unsigned CaseIndex = 0; CaseIndex < NumCases; 2227 for (unsigned CaseIndex = 0; CaseIndex < NumCases;
2232 ++CaseIndex, ValCaseIndex += 4) { 2228 ++CaseIndex, ValCaseIndex += 4) {
2233 if (Values[ValCaseIndex] != 1 || Values[ValCaseIndex+1] != 1) { 2229 if (Values[ValCaseIndex] != 1 || Values[ValCaseIndex + 1] != 1) {
2234 std::string Buffer; 2230 std::string Buffer;
2235 raw_string_ostream StrBuf(Buffer); 2231 raw_string_ostream StrBuf(Buffer);
2236 StrBuf << "Sequence [1, 1, value, label] expected for case entry " 2232 StrBuf << "Sequence [1, 1, value, label] expected for case entry "
2237 << "in switch record. (at index" << ValCaseIndex << ")"; 2233 << "in switch record. (at index" << ValCaseIndex << ")";
2238 Error(StrBuf.str()); 2234 Error(StrBuf.str());
2239 return; 2235 return;
2240 } 2236 }
2241 Ice::APInt Value(BitWidth, 2237 Ice::APInt Value(BitWidth,
2242 NaClDecodeSignRotatedValue(Values[ValCaseIndex + 2])); 2238 NaClDecodeSignRotatedValue(Values[ValCaseIndex + 2]));
2243 if (isIRGenDisabled) 2239 if (isIRGenDisabled)
2244 continue; 2240 continue;
2245 Ice::CfgNode *Label = getBranchBasicBlock(Values[ValCaseIndex + 3]); 2241 Ice::CfgNode *Label = getBranchBasicBlock(Values[ValCaseIndex + 3]);
2246 Switch->addBranch(CaseIndex, Value.getSExtValue(), Label); 2242 Switch->addBranch(CaseIndex, Value.getSExtValue(), Label);
2247 } 2243 }
2248 if (isIRGenDisabled) 2244 if (isIRGenDisabled)
2249 return; 2245 return;
2250 CurrentNode->appendInst(Switch); 2246 CurrentNode->appendInst(Switch);
2251 InstIsTerminating = true; 2247 InstIsTerminating = true;
2252 return; 2248 return;
2253 } 2249 }
2254 case naclbitc::FUNC_CODE_INST_UNREACHABLE: { 2250 case naclbitc::FUNC_CODE_INST_UNREACHABLE: {
2255 // UNREACHABLE: [] 2251 // UNREACHABLE: []
2256 if (!isValidRecordSize(0, "unreachable")) 2252 if (!isValidRecordSize(0, "unreachable"))
2257 return; 2253 return;
2258 if (isIRGenerationDisabled()) 2254 if (isIRGenerationDisabled())
2259 return; 2255 return;
2260 CurrentNode->appendInst( 2256 CurrentNode->appendInst(Ice::InstUnreachable::create(Func));
2261 Ice::InstUnreachable::create(Func));
2262 InstIsTerminating = true; 2257 InstIsTerminating = true;
2263 return; 2258 return;
2264 } 2259 }
2265 case naclbitc::FUNC_CODE_INST_PHI: { 2260 case naclbitc::FUNC_CODE_INST_PHI: {
2266 // PHI: [ty, val1, bb1, ..., valN, bbN] for n >= 2. 2261 // PHI: [ty, val1, bb1, ..., valN, bbN] for n >= 2.
2267 if (!isValidRecordSizeAtLeast(3, "phi")) 2262 if (!isValidRecordSizeAtLeast(3, "phi"))
2268 return; 2263 return;
2269 Ice::Type Ty = Context->getSimpleTypeByID(Values[0]); 2264 Ice::Type Ty = Context->getSimpleTypeByID(Values[0]);
2270 if ((Values.size() & 0x1) == 0) { 2265 if ((Values.size() & 0x1) == 0) {
2271 // Not an odd number of values. 2266 // Not an odd number of values.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 setNextLocalInstIndex(nullptr); 2452 setNextLocalInstIndex(nullptr);
2458 return; 2453 return;
2459 } 2454 }
2460 2455
2461 // Create the call instruction. 2456 // Create the call instruction.
2462 Ice::Variable *Dest = (ReturnType == Ice::IceType_void) 2457 Ice::Variable *Dest = (ReturnType == Ice::IceType_void)
2463 ? nullptr 2458 ? nullptr
2464 : getNextInstVar(ReturnType); 2459 : getNextInstVar(ReturnType);
2465 Ice::InstCall *Inst = nullptr; 2460 Ice::InstCall *Inst = nullptr;
2466 if (IntrinsicInfo) { 2461 if (IntrinsicInfo) {
2467 Inst = 2462 Inst = Ice::InstIntrinsicCall::create(Func, NumParams, Dest, Callee,
2468 Ice::InstIntrinsicCall::create(Func, NumParams, Dest, Callee, 2463 IntrinsicInfo->Info);
2469 IntrinsicInfo->Info);
2470 } else { 2464 } else {
2471 Inst = Ice::InstCall::create(Func, NumParams, Dest, Callee, IsTailCall); 2465 Inst = Ice::InstCall::create(Func, NumParams, Dest, Callee, IsTailCall);
2472 } 2466 }
2473 2467
2474 // Add parameters. 2468 // Add parameters.
2475 for (Ice::SizeT ParamIndex = 0; ParamIndex < NumParams; ++ParamIndex) { 2469 for (Ice::SizeT ParamIndex = 0; ParamIndex < NumParams; ++ParamIndex) {
2476 Inst->addArg( 2470 Inst->addArg(
2477 getRelativeOperand(Values[ParamsStartIndex + ParamIndex], BaseIndex)); 2471 getRelativeOperand(Values[ParamsStartIndex + ParamIndex], BaseIndex));
2478 } 2472 }
2479 2473
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 if (!Decl->hasName()) { 2795 if (!Decl->hasName()) {
2802 Decl->setName(Trans.createUnnamedName(Prefix, NameIndex)); 2796 Decl->setName(Trans.createUnnamedName(Prefix, NameIndex));
2803 ++NameIndex; 2797 ++NameIndex;
2804 } else { 2798 } else {
2805 Trans.checkIfUnnamedNameSafe(Decl->getName(), Context, Prefix); 2799 Trans.checkIfUnnamedNameSafe(Decl->getName(), Context, Prefix);
2806 } 2800 }
2807 } 2801 }
2808 2802
2809 bool ParseBlock(unsigned BlockID) override; 2803 bool ParseBlock(unsigned BlockID) override;
2810 2804
2811 void ExitBlock() override { 2805 void ExitBlock() override { InstallGlobalNamesAndGlobalVarInitializers(); }
2812 InstallGlobalNamesAndGlobalVarInitializers();
2813 }
2814 2806
2815 void ProcessRecord() override; 2807 void ProcessRecord() override;
2816 }; 2808 };
2817 2809
2818 class ModuleValuesymtabParser : public ValuesymtabParser { 2810 class ModuleValuesymtabParser : public ValuesymtabParser {
2819 ModuleValuesymtabParser(const ModuleValuesymtabParser &) = delete; 2811 ModuleValuesymtabParser(const ModuleValuesymtabParser &) = delete;
2820 void operator=(const ModuleValuesymtabParser &) = delete; 2812 void operator=(const ModuleValuesymtabParser &) = delete;
2821 2813
2822 public: 2814 public:
2823 ModuleValuesymtabParser(unsigned BlockID, ModuleParser *MP) 2815 ModuleValuesymtabParser(unsigned BlockID, ModuleParser *MP)
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2986 2978
2987 if (TopLevelBlocks != 1) { 2979 if (TopLevelBlocks != 1) {
2988 errs() << IRFilename 2980 errs() << IRFilename
2989 << ": Contains more than one module. Found: " << TopLevelBlocks 2981 << ": Contains more than one module. Found: " << TopLevelBlocks
2990 << "\n"; 2982 << "\n";
2991 ErrorStatus.assign(EC_Bitcode); 2983 ErrorStatus.assign(EC_Bitcode);
2992 } 2984 }
2993 } 2985 }
2994 2986
2995 } // end of namespace Ice 2987 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTypes.cpp ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698