Arquivos
hhvm/hphp/runtime/vm/jit/irfactory.cpp
T
bsimmers cf197fee81 Collapse runtime/vm/translator's contents into runtime/vm/jit
Facebook: ~bsimmers/bin/move-vm-files.sh
2013-06-03 10:54:43 -07:00

59 linhas
2.1 KiB
C++

/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/vm/jit/irfactory.h"
#include "hphp/runtime/vm/jit/block.h"
namespace HPHP { namespace JIT {
IRInstruction* IRFactory::defLabel(unsigned numDst) {
IRInstruction inst(DefLabel);
IRInstruction* label = cloneInstruction(&inst);
if (numDst > 0) {
SSATmp* dsts = (SSATmp*) m_arena.alloc(numDst * sizeof(SSATmp));
for (unsigned i = 0; i < numDst; ++i) {
new (&dsts[i]) SSATmp(m_nextOpndId++, label);
}
label->setDsts(numDst, dsts);
}
return label;
}
Block* IRFactory::defBlock(const Func* func) {
return new (m_arena) Block(m_nextBlockId++, func);
}
IRInstruction* IRFactory::mov(SSATmp* dst, SSATmp* src) {
IRInstruction* inst = gen(Mov, dst->type(), src);
dst->setInstruction(inst);
inst->setDst(dst);
return inst;
}
SSATmp* IRFactory::findConst(ConstData& cdata, Type ctype) {
IRInstruction inst(DefConst);
inst.setExtra(&cdata);
inst.setTypeParam(ctype);
if (SSATmp* tmp = m_constTable.lookup(&inst)) {
assert(tmp->type().equals(ctype));
return tmp;
}
return m_constTable.insert(cloneInstruction(&inst)->dst());
}
}}