}
}
+ uint32_t GenContext::createGenReg(ir::Register reg, uint32_t grfOffset) {
+ using namespace ir;
+ if (fn.isSpecialReg(reg) == true) return grfOffset; // already done
+ if (fn.getInput(reg) != NULL) return grfOffset; // already done
+ const RegisterData regData = fn.getRegisterData(reg);
+ const uint32_t typeSize = regData.getSize();
+ const uint32_t regSize = simdWidth*typeSize;
+ grfOffset = ALIGN(grfOffset, regSize);
+ if (grfOffset + regSize <= GEN_GRF_SIZE) {
+ const uint32_t nr = grfOffset / GEN_REG_SIZE;
+ const uint32_t subnr = (grfOffset % GEN_REG_SIZE) / typeSize;
+ if (simdWidth == 16)
+ RA.insert(std::make_pair(reg, GenReg::f16grf(nr, subnr)));
+ else if (simdWidth == 8)
+ RA.insert(std::make_pair(reg, GenReg::f8grf(nr, subnr)));
+ else
+ NOT_SUPPORTED;
+ grfOffset += simdWidth * typeSize;
+ } else
+ NOT_SUPPORTED;
+ return grfOffset;
+ }
+
void GenContext::allocateRegister(void) {
using namespace ir;
GBE_ASSERT(fn.getProfile() == PROFILE_OCL);
// Allocate all used registers. Just crash when we run out-of-registers
uint32_t grfOffset = kernel->getCurbeSize() + GEN_REG_SIZE;
- GBE_ASSERT(simdWidth != 32); // XXX a bit more complicated see later
- if (simdWidth == 16) grfOffset = ALIGN(grfOffset, 2*GEN_REG_SIZE);
- for (auto reg : usedRegs) {
- if (fn.isSpecialReg(reg) == true) continue; // already done
- if (fn.getInput(reg) != NULL) continue; // already done
- const RegisterData regData = fn.getRegisterData(reg);
- const uint32_t typeSize = regData.getSize();
- const uint32_t regSize = simdWidth*typeSize;
- grfOffset = ALIGN(grfOffset, regSize);
- if (grfOffset + regSize <= GEN_GRF_SIZE) {
- const uint32_t nr = grfOffset / GEN_REG_SIZE;
- const uint32_t subnr = (grfOffset % GEN_REG_SIZE) / typeSize;
- if (simdWidth == 16)
- RA.insert(std::make_pair(reg, GenReg::f16grf(nr, subnr)));
- else if (simdWidth == 8)
- RA.insert(std::make_pair(reg, GenReg::f8grf(nr, subnr)));
- else
- NOT_SUPPORTED;
- grfOffset += simdWidth * typeSize;
- } else
- NOT_IMPLEMENTED;
- }
+ for (auto reg : usedRegs)
+ grfOffset = this->createGenReg(reg, grfOffset);
}
void GenContext::emitUnaryInstruction(const ir::UnaryInstruction &insn) {
void allocatePayloadReg(gbe_curbe_type value, uint32_t subValue, const ir::Register ®);
/*! Very stupid register allocator to start with */
void allocateRegister(void);
+ /*! Create a GenReg from a ir::Register */
+ uint32_t createGenReg(ir::Register reg, uint32_t grfOffset);
/*! Emit the instructions */
void emitInstructionStream(void);
/*! Set the correct target values for the branches */
}
}
- /* Returns the corresponding conditional mod for swapping src0 and
- * src1 in e.g. CMP.
- */
- uint32_t brw_swap_cmod(uint32_t cmod)
- {
- switch (cmod) {
- case GEN_CONDITIONAL_Z:
- case GEN_CONDITIONAL_NZ:
- return cmod;
- case GEN_CONDITIONAL_G:
- return GEN_CONDITIONAL_LE;
- case GEN_CONDITIONAL_GE:
- return GEN_CONDITIONAL_L;
- case GEN_CONDITIONAL_L:
- return GEN_CONDITIONAL_GE;
- case GEN_CONDITIONAL_LE:
- return GEN_CONDITIONAL_G;
- default:
- return ~0;
- }
- }
-
void GenEmitter::setDst(GenInstruction *insn, GenReg dest)
{
if (dest.file != GEN_ARCHITECTURE_REGISTER_FILE)