First cut at new loop codegen.

Change-Id: Id3bdf8b7a5606e7ce5d856ef225d5ddbe59a584b
This commit is contained in:
Dejan Mircevski
2016-01-10 12:15:13 -05:00
parent c92e370e87
commit 9c6734c8df
4 changed files with 93 additions and 52 deletions

View File

@@ -378,6 +378,13 @@ public:
// The loopTestFirst parameter is true when the loop test executes before
// the body. (It is false for do-while loops.)
void makeNewLoop(bool loopTestFirst);
struct LoopBlocks {
Block &body, &merge, &continue_target;
};
LoopBlocks makeNewLoop();
// Create a new block in the function containing the build point.
Block& makeNewBlock();
// Add the branch for the loop test, based on the given condition.
// The true branch goes to the first block in the loop body, and
@@ -494,7 +501,11 @@ public:
void dump(std::vector<unsigned int>&) const;
protected:
void createBranch(Block* block);
void createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock);
void createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned int control);
protected:
Id makeIntConstant(Id typeId, unsigned value, bool specConstant);
Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value) const;
Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2) const;
@@ -503,10 +514,7 @@ protected:
void transferAccessChainSwizzle(bool dynamic);
void simplifyAccessChainSwizzle();
void createAndSetNoPredecessorBlock(const char*);
void createBranch(Block* block);
void createSelectionMerge(Block* mergeBlock, unsigned int control);
void createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned int control);
void createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock);
void dumpInstructions(std::vector<unsigned int>&, const std::vector<Instruction*>&) const;
struct Loop; // Defined below.