| 131 | } |
| 132 | |
| 133 | std::string CodeGenerator::Build() const { |
| 134 | std::ostringstream ss; |
| 135 | |
| 136 | ss << capabilities_; |
| 137 | ss << extensions_; |
| 138 | ss << memory_model_; |
| 139 | |
| 140 | for (const EntryPoint& entry_point : entry_points_) { |
| 141 | ss << "OpEntryPoint " << entry_point.execution_model << " %" |
| 142 | << entry_point.name << " \"" << entry_point.name << "\" " |
| 143 | << entry_point.interfaces << "\n"; |
| 144 | } |
| 145 | |
| 146 | for (const EntryPoint& entry_point : entry_points_) { |
| 147 | ss << entry_point.execution_modes << "\n"; |
| 148 | } |
| 149 | |
| 150 | ss << before_types_; |
| 151 | ss << types_; |
| 152 | ss << after_types_; |
| 153 | |
| 154 | for (const EntryPoint& entry_point : entry_points_) { |
| 155 | ss << "\n"; |
| 156 | ss << "%" << entry_point.name << " = OpFunction %void None %func\n"; |
| 157 | ss << "%" << entry_point.name << "_entry = OpLabel\n"; |
| 158 | ss << entry_point.body; |
| 159 | ss << "\nOpReturn\nOpFunctionEnd\n"; |
| 160 | } |
| 161 | |
| 162 | ss << add_at_the_end_; |
| 163 | |
| 164 | return ss.str(); |
| 165 | } |
| 166 | |
| 167 | } // namespace val |
| 168 | } // namespace spvtools |