diff options
author | Zack Rusin <zack@tungstengraphics.com> | 2007-10-24 19:20:19 -0400 |
---|---|---|
committer | Zack Rusin <zack@tungstengraphics.com> | 2007-10-24 19:20:32 -0400 |
commit | 1c5fec714d30c02d6d00d95215c2e302c4c65cc3 (patch) | |
tree | 084ff82f7b39e25c17447ba211295f963fcf6b17 /src/mesa/pipe/llvm/storage.cpp | |
parent | 7636aac54bb357ce907ae6cc2c41f32957faecf3 (diff) |
Simplify branch handling. Prepare for proper decleration extraction.
Diffstat (limited to 'src/mesa/pipe/llvm/storage.cpp')
-rw-r--r-- | src/mesa/pipe/llvm/storage.cpp | 66 |
1 files changed, 16 insertions, 50 deletions
diff --git a/src/mesa/pipe/llvm/storage.cpp b/src/mesa/pipe/llvm/storage.cpp index 75ee18567d..6721f387c8 100644 --- a/src/mesa/pipe/llvm/storage.cpp +++ b/src/mesa/pipe/llvm/storage.cpp @@ -192,31 +192,29 @@ llvm::Value *Storage::shuffleVector(llvm::Value *vec, int shuffle) } -llvm::Value *Storage::tempElement(int idx) const +llvm::Value *Storage::tempElement(int idx) { - Value *ret = m_temps[idx]; - if (!ret) + Value *ptr = m_temps[idx]; + if (!ptr) return m_undefFloatVec; - return ret; + llvm::LoadInst *li = new LoadInst(ptr, name("temp"), + false, m_block); + li->setAlignment(8); + return li; } void Storage::setTempElement(int idx, llvm::Value *val, int mask) { if (mask != TGSI_WRITEMASK_XYZW) { - llvm::Value *templ = m_temps[idx]; + llvm::Value *templ = 0; + if (m_temps[idx]) + templ = tempElement(idx); val = maskWrite(val, mask, templ); } - llvm::Value *templ = m_temps[idx]; - if (templ) { - BasicBlock *block = m_varBlocks[templ]; - if (block != m_block) { - addPhiNode(idx, val, m_block, templ, block); - } else - updatePhiNode(idx, val); - } - - m_temps[idx] = val; - m_varBlocks[val] = m_block; + llvm::Value *ptr = m_temps[idx]; + assert(ptr); + StoreInst *st = new StoreInst(val, ptr, false, m_block); + st->setAlignment(8); } void Storage::store(int dstIdx, llvm::Value *val, int mask) @@ -308,39 +306,7 @@ void Storage::setCurrentBlock(llvm::BasicBlock *block) m_block = block; } -void Storage::addPhiNode(int idx, llvm::Value *val1, llvm::BasicBlock *blk1, - llvm::Value *val2, llvm::BasicBlock *blk2) -{ - PhiNode node; - node.val1 = val1; - node.block1 = blk1; - node.val2 = val2; - node.block2 = blk2; - m_phiNodes[idx] = node; -} - -void Storage::updatePhiNode(int idx, llvm::Value *val1) -{ - if (m_phiNodes.find(idx) == m_phiNodes.end()) - return; - PhiNode node = m_phiNodes[idx]; - node.val1 = val1; - m_phiNodes[idx] = node; -} - -void Storage::popPhiNode() +void Storage::declareTemp(int idx) { - if (!m_phiNodes.empty()) { - std::map<int, PhiNode>::const_iterator itr; - for (itr = m_phiNodes.begin(); itr != m_phiNodes.end(); ++itr) { - PhiNode node = (*itr).second; - PHINode *dest = new PHINode(m_floatVecType, - name("phiDest"), m_block); - dest->reserveOperandSpace(2); - dest->addIncoming(node.val1, node.block1); - dest->addIncoming(node.val2, node.block2); - m_temps[(*itr).first] = dest; - } - } - m_phiNodes.clear(); + m_temps[idx] = new AllocaInst(m_floatVecType, name("temp"), m_block); } |