1 // SwiftShader Software Renderer
\r
3 // Copyright(c) 2005-2011 TransGaming Inc.
\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,
\r
6 // transcribed, stored in a retrieval system, translated into any human or computer
\r
7 // language by any means, or disclosed to third parties without the explicit written
\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
\r
9 // or implied, including but not limited to any patent rights, are granted to you.
\r
12 #include "Nucleus.hpp"
\r
13 #include "Routine.hpp"
\r
17 #define For(init, cond, inc) \
\r
19 for(llvm::BasicBlock *loopBB__ = beginLoop(), \
\r
20 *bodyBB__ = Nucleus::createBasicBlock(), \
\r
21 *endBB__ = Nucleus::createBasicBlock(), \
\r
22 *onceBB__ = endBB__; \
\r
23 onceBB__ && branch(cond, bodyBB__, endBB__); \
\r
24 inc, onceBB__ = 0, Nucleus::createBr(loopBB__), Nucleus::setInsertBlock(endBB__))
\r
26 #define While(cond) For(((void*)0), cond, ((void*)0))
\r
30 llvm::BasicBlock *body = Nucleus::createBasicBlock(); \
\r
31 Nucleus::createBr(body); \
\r
32 Nucleus::setInsertBlock(body);
\r
34 #define Until(cond) \
\r
35 llvm::BasicBlock *end = Nucleus::createBasicBlock(); \
\r
36 Nucleus::createCondBr((cond).value, end, body); \
\r
37 Nucleus::setInsertBlock(end); \
\r
41 for(llvm::BasicBlock *trueBB__ = Nucleus::createBasicBlock(), \
\r
42 *falseBB__ = Nucleus::createBasicBlock(), \
\r
43 *endBB__ = Nucleus::createBasicBlock(), \
\r
44 *onceBB__ = endBB__; \
\r
45 onceBB__ && branch(cond, trueBB__, falseBB__); \
\r
46 onceBB__ = 0, Nucleus::createBr(endBB__), Nucleus::setInsertBlock(falseBB__), Nucleus::createBr(endBB__), Nucleus::setInsertBlock(endBB__))
\r
49 for(llvm::BasicBlock *endBB__ = Nucleus::getInsertBlock(), \
\r
50 *falseBB__ = Nucleus::getPredecessor(endBB__), \
\r
51 *onceBB__ = endBB__; \
\r
52 onceBB__ && elseBlock(falseBB__); \
\r
53 onceBB__ = 0, Nucleus::createBr(endBB__), Nucleus::setInsertBlock(endBB__))
\r