OSDN Git Service

Split off Routine into its own file.
[android-x86/external-swiftshader.git] / src / Reactor / Reactor.hpp
1 // SwiftShader Software Renderer\r
2 //\r
3 // Copyright(c) 2005-2011 TransGaming Inc.\r
4 //\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
10 //\r
11 \r
12 #include "Nucleus.hpp"\r
13 #include "Routine.hpp"\r
14 \r
15 namespace sw\r
16 {\r
17         #define For(init, cond, inc)                     \\r
18         init;                                            \\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
25 \r
26         #define While(cond) For(((void*)0), cond, ((void*)0))\r
27 \r
28         #define Do \\r
29         { \\r
30                 llvm::BasicBlock *body = Nucleus::createBasicBlock(); \\r
31                 Nucleus::createBr(body); \\r
32                 Nucleus::setInsertBlock(body);\r
33 \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
38         }\r
39 \r
40         #define If(cond)                                                              \\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
47 \r
48         #define Else                                            \\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
54 }