Add a test for loop without a condition.
Change-Id: Idd7fc462218a84b1e745207e2975a3f2897d30a0
builder.setBuildPoint(&blocks.body);
if (node->getBody())
- node->getBody()->traverse(this); // continue->cont, break->exit
+ node->getBody()->traverse(this);
builder.createBranch(&blocks.continue_target);
builder.setBuildPoint(&blocks.continue_target);
builder.setBuildPoint(&blocks.body);
if (node->getBody())
- node->getBody()->traverse(this); // continue->cont, break->exit
+ node->getBody()->traverse(this);
builder.createBranch(&blocks.continue_target);
builder.setBuildPoint(&blocks.continue_target);
if (unreachable) {
// Given that this block is at the end of a function, it must be right after an
// explicit return, just remove it.
- function.popBlock(block);
+ function.removeBlock(block);
} else {
// We'll add a return instruction at the end of the current block,
// which for a non-void function is really error recovery (?), as the source
#include "spirv.hpp"
+#include <algorithm>
#include <vector>
#include <iostream>
#include <assert.h>
Id getParamId(int p) { return parameterInstructions[p]->getResultId(); }
void addBlock(Block* block) { blocks.push_back(block); }
- void popBlock(Block*) { blocks.pop_back(); }
+ void removeBlock(Block* block)
+ {
+ auto found = find(blocks.begin(), blocks.end(), block);
+ assert(found != blocks.end());
+ blocks.erase(found);
+ delete block;
+ }
Module& getParent() const { return parent; }
Block* getEntryBlock() const { return blocks.front(); }
--- /dev/null
+spv.for-notest.vert\r
+Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.\r
+\r
+\r
+Linked vertex stage:\r
+\r
+\r
+// Module Version 10000\r
+// Generated by (magic number): 80001\r
+// Id's are bound by 22\r
+\r
+ Capability Shader\r
+ 1: ExtInstImport "GLSL.std.450"\r
+ MemoryModel Logical GLSL450\r
+ EntryPoint Vertex 4 "main" 14 20 21\r
+ Source GLSL 450\r
+ Name 4 "main"\r
+ Name 8 "i"\r
+ Name 14 "r"\r
+ Name 20 "gl_VertexID"\r
+ Name 21 "gl_InstanceID"\r
+ Decorate 14(r) Location 0\r
+ Decorate 20(gl_VertexID) BuiltIn VertexId\r
+ Decorate 21(gl_InstanceID) BuiltIn InstanceId\r
+ 2: TypeVoid\r
+ 3: TypeFunction 2\r
+ 6: TypeInt 32 1\r
+ 7: TypePointer Function 6(int)\r
+ 9: 6(int) Constant 0\r
+ 13: TypePointer Output 6(int)\r
+ 14(r): 13(ptr) Variable Output\r
+ 17: 6(int) Constant 1\r
+ 19: TypePointer Input 6(int)\r
+ 20(gl_VertexID): 19(ptr) Variable Input\r
+21(gl_InstanceID): 19(ptr) Variable Input\r
+ 4(main): 2 Function None 3\r
+ 5: Label\r
+ 8(i): 7(ptr) Variable Function\r
+ Store 8(i) 9\r
+ Branch 10\r
+ 10: Label\r
+ 15: 6(int) Load 8(i)\r
+ Store 14(r) 15\r
+ Branch 12\r
+ 12: Label\r
+ 16: 6(int) Load 8(i)\r
+ 18: 6(int) IAdd 16 17\r
+ Store 8(i) 18\r
+ Branch 10\r
+ FunctionEnd\r
--- /dev/null
+#version 450
+layout(location=0) out highp int r;
+void main() {
+ int i;
+ for (i=0; ; i++) { r = i; }
+}