| OLD | NEW |
| 1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===// | 1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===// |
| 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 notion of function declarations, global | 10 // This file implements the notion of function declarations, global |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 std::string Buffer; | 53 std::string Buffer; |
| 54 llvm::raw_string_ostream StrBuf(Buffer); | 54 llvm::raw_string_ostream StrBuf(Buffer); |
| 55 StrBuf << "Unknown calling convention: " << CallingConv; | 55 StrBuf << "Unknown calling convention: " << CallingConv; |
| 56 llvm::report_fatal_error(StrBuf.str()); | 56 llvm::report_fatal_error(StrBuf.str()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // end of anonymous namespace | 59 } // end of anonymous namespace |
| 60 | 60 |
| 61 namespace Ice { | 61 namespace Ice { |
| 62 | 62 |
| 63 FunctionDeclaration *FunctionDeclaration::create( | |
| 64 const FuncSigType &Signature, llvm::CallingConv::ID CallingConv, | |
| 65 llvm::GlobalValue::LinkageTypes Linkage, bool IsProto) { | |
| 66 return new FunctionDeclaration(Signature, CallingConv, Linkage, IsProto); | |
| 67 } | |
| 68 | |
| 69 void FunctionDeclaration::dumpType(Ostream &Stream) const { | 63 void FunctionDeclaration::dumpType(Ostream &Stream) const { |
| 70 if (!ALLOW_DUMP) | 64 if (!ALLOW_DUMP) |
| 71 return; | 65 return; |
| 72 Stream << Signature; | 66 Stream << Signature; |
| 73 } | 67 } |
| 74 | 68 |
| 75 void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { | 69 void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { |
| 76 if (!ALLOW_DUMP) | 70 if (!ALLOW_DUMP) |
| 77 return; | 71 return; |
| 78 if (IsProto) | 72 if (IsProto) |
| 79 Stream << "declare "; | 73 Stream << "declare "; |
| 80 ::dumpLinkage(Stream, Linkage); | 74 ::dumpLinkage(Stream, Linkage); |
| 81 ::dumpCallingConv(Stream, CallingConv); | 75 ::dumpCallingConv(Stream, CallingConv); |
| 82 Stream << Signature.getReturnType() << " @" | 76 Stream << Signature.getReturnType() << " @" |
| 83 << (Ctx ? Ctx->mangleName(Name) : Name) << "("; | 77 << (Ctx ? Ctx->mangleName(Name) : Name) << "("; |
| 84 bool IsFirst = true; | 78 bool IsFirst = true; |
| 85 for (Type ArgTy : Signature.getArgList()) { | 79 for (Type ArgTy : Signature.getArgList()) { |
| 86 if (IsFirst) | 80 if (IsFirst) |
| 87 IsFirst = false; | 81 IsFirst = false; |
| 88 else | 82 else |
| 89 Stream << ", "; | 83 Stream << ", "; |
| 90 Stream << ArgTy; | 84 Stream << ArgTy; |
| 91 } | 85 } |
| 92 Stream << ")"; | 86 Stream << ")"; |
| 93 } | 87 } |
| 94 | 88 |
| 95 VariableDeclaration *VariableDeclaration::create() { | |
| 96 return new VariableDeclaration(); | |
| 97 } | |
| 98 | |
| 99 VariableDeclaration::~VariableDeclaration() { | |
| 100 llvm::DeleteContainerPointers(Initializers); | |
| 101 } | |
| 102 | |
| 103 void VariableDeclaration::dumpType(Ostream &Stream) const { | 89 void VariableDeclaration::dumpType(Ostream &Stream) const { |
| 104 if (!ALLOW_DUMP) | 90 if (!ALLOW_DUMP) |
| 105 return; | 91 return; |
| 106 if (Initializers.size() == 1) { | 92 if (Initializers->size() == 1) { |
| 107 Initializers.front()->dumpType(Stream); | 93 Initializers->front()->dumpType(Stream); |
| 108 } else { | 94 } else { |
| 109 Stream << "<{ "; | 95 Stream << "<{ "; |
| 110 bool IsFirst = true; | 96 bool IsFirst = true; |
| 111 for (Initializer *Init : Initializers) { | 97 for (const std::unique_ptr<Initializer> &Init : *Initializers) { |
| 112 if (IsFirst) { | 98 if (IsFirst) { |
| 113 IsFirst = false; | 99 IsFirst = false; |
| 114 } else { | 100 } else { |
| 115 Stream << ", "; | 101 Stream << ", "; |
| 116 } | 102 } |
| 117 Init->dumpType(Stream); | 103 Init->dumpType(Stream); |
| 118 } | 104 } |
| 119 Stream << " }>"; | 105 Stream << " }>"; |
| 120 } | 106 } |
| 121 } | 107 } |
| 122 | 108 |
| 123 void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { | 109 void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { |
| 124 if (!ALLOW_DUMP) | 110 if (!ALLOW_DUMP) |
| 125 return; | 111 return; |
| 126 Stream << "@" | 112 Stream << "@" |
| 127 << ((Ctx && !getSuppressMangling()) ? Ctx->mangleName(Name) : Name) | 113 << ((Ctx && !getSuppressMangling()) ? Ctx->mangleName(Name) : Name) |
| 128 << " = "; | 114 << " = "; |
| 129 ::dumpLinkage(Stream, Linkage); | 115 ::dumpLinkage(Stream, Linkage); |
| 130 Stream << " " << (IsConstant ? "constant" : "global") << " "; | 116 Stream << " " << (IsConstant ? "constant" : "global") << " "; |
| 131 | 117 |
| 132 // Add initializer. | 118 // Add initializer. |
| 133 if (Initializers.size() == 1) { | 119 if (Initializers->size() == 1) { |
| 134 Initializers.front()->dump(Stream); | 120 Initializers->front()->dump(Stream); |
| 135 } else { | 121 } else { |
| 136 dumpType(Stream); | 122 dumpType(Stream); |
| 137 Stream << " <{ "; | 123 Stream << " <{ "; |
| 138 bool IsFirst = true; | 124 bool IsFirst = true; |
| 139 for (Initializer *Init : Initializers) { | 125 for (const std::unique_ptr<Initializer> &Init : *Initializers) { |
| 140 if (IsFirst) { | 126 if (IsFirst) { |
| 141 IsFirst = false; | 127 IsFirst = false; |
| 142 } else { | 128 } else { |
| 143 Stream << ", "; | 129 Stream << ", "; |
| 144 } | 130 } |
| 145 Init->dump(Ctx, Stream); | 131 Init->dump(Ctx, Stream); |
| 146 } | 132 } |
| 147 Stream << " }>"; | 133 Stream << " }>"; |
| 148 } | 134 } |
| 149 | 135 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 dumpType(Stream); | 197 dumpType(Stream); |
| 212 Stream << ")"; | 198 Stream << ")"; |
| 213 if (Offset != 0) { | 199 if (Offset != 0) { |
| 214 Stream << ", "; | 200 Stream << ", "; |
| 215 dumpType(Stream); | 201 dumpType(Stream); |
| 216 Stream << " " << Offset << ")"; | 202 Stream << " " << Offset << ")"; |
| 217 } | 203 } |
| 218 } | 204 } |
| 219 | 205 |
| 220 } // end of namespace Ice | 206 } // end of namespace Ice |
| OLD | NEW |