if (srcID != 0) continue;
const unsigned char bti = ir::cast<ir::GetImageInfoInstruction>(insn).getImageIndex();
const unsigned char type = ir::cast<ir::GetImageInfoInstruction>(insn).getInfoType();;
- ir::ImageInfoKey key;
- key.index = bti;
- key.type = type;
- const ir::Register imageInfo(key.data | 0x8000);
- ir::Register realImageInfo;
+ ir::ImageInfoKey key(bti, type);
+ const ir::Register imageInfo = insn.getSrc(0);
if (curbeRegs.find(imageInfo) == curbeRegs.end()) {
uint32_t offset = this->getImageInfoCurbeOffset(key, 4);
- realImageInfo = insn.getSrc(0);
- insertCurbeReg(realImageInfo, offset);
- insertCurbeReg(imageInfo, (uint32_t)realImageInfo);
- } else {
- realImageInfo = ir::Register(curbeRegs.find(imageInfo)->second);
- insn.setSrc(0, realImageInfo);
+ insertCurbeReg(imageInfo, offset);
}
continue;
} else if (insn.getOpcode() == ir::OP_GET_SAMPLER_INFO) {
p->pop();
}
- void GenContext::emitGetImageInfoInstruction(const SelectionInstruction &insn) {
- const unsigned char bti = insn.extra.function;
- const unsigned char type = insn.extra.elem;
- const uint32_t dstNum = ir::GetImageInfoInstruction::getDstNum4Type(type);
- ir::ImageInfoKey key;
- key.index = bti;
- key.type = type;
-
- uint32_t offset = this->getImageInfoCurbeOffset(key, dstNum * 4) + GEN_REG_SIZE;
- for(uint32_t i = 0; i < dstNum; i++) {
- const uint32_t nr = offset / GEN_REG_SIZE;
- const uint32_t subnr = (offset % GEN_REG_SIZE) / sizeof(uint32_t);
- p->MOV(ra->genReg(insn.dst(i)), GenRegister::ud1grf(nr, subnr));
- offset += 32;
- }
- }
-
BVAR(OCL_OUTPUT_REG_ALLOC, false);
BVAR(OCL_OUTPUT_ASM, false);
bool GenContext::emitCode(void) {
DECL_GEN7_SCHEDULE(TypedWrite, 80, 1, 1)
DECL_GEN7_SCHEDULE(SpillReg, 80, 1, 1)
DECL_GEN7_SCHEDULE(UnSpillReg, 80, 1, 1)
-DECL_GEN7_SCHEDULE(GetImageInfo, 20, 4, 2)
DECL_GEN7_SCHEDULE(Atomic, 80, 1, 1)
DECL_GEN7_SCHEDULE(I64MUL, 20, 4, 2)
DECL_GEN7_SCHEDULE(I64SATADD, 20, 4, 2)
DECL_SELECTION_IR(DWORD_GATHER, DWordGatherInstruction)
DECL_SELECTION_IR(SAMPLE, SampleInstruction)
DECL_SELECTION_IR(TYPED_WRITE, TypedWriteInstruction)
-DECL_SELECTION_IR(GET_IMAGE_INFO, GetImageInfoInstruction)
DECL_SELECTION_IR(SPILL_REG, SpillRegInstruction)
DECL_SELECTION_IR(UNSPILL_REG, UnSpillRegInstruction)
DECL_SELECTION_IR(MUL_HI, BinaryWithTempInstruction)
INLINE void GenRegAllocator::Opaque::allocatePayloadRegs(void) {
using namespace ir;
for(auto &it : this->ctx.curbeRegs)
- if (it.first.value() < 0x8000)
- allocatePayloadReg(it.first, it.second);
+ allocatePayloadReg(it.first, it.second);
// Allocate all pushed registers (i.e. structure kernel arguments)
const Function &fn = ctx.getFunction();
setInfoOffset4Type(imageInfo, key.type, offset);
}
+ Register ImageSet::appendInfo(ImageInfoKey key, Context *ctx)
+ {
+ auto it = infoRegMap.find(key.data);
+ if (it != infoRegMap.end())
+ return it->second;
+ Register reg = ctx->reg(FAMILY_DWORD);
+ infoRegMap.insert(std::make_pair(key.data, reg));
+ return reg;
+ }
+
void ImageSet::clearInfo()
{
struct ImageInfo *imageInfo;
void append(Register imageReg, Context *ctx);
/*! Append an image info slot. */
void appendInfo(ImageInfoKey key, uint32_t offset);
+ /*! Append an image info register. */
+ Register appendInfo(ImageInfoKey, Context *ctx);
/*! clear image info. */
void clearInfo();
/*! Get the image's index(actual location). */
private:
map<Register, struct ImageInfo *> regMap;
map<uint32_t, struct ImageInfo *> indexMap;
+ map<uint32_t, Register> infoRegMap;
GBE_CLASS(ImageSet);
};
} /* namespace ir */
static bool isClassOf(const Instruction &insn);
};
- typedef union {
+ typedef union _ImageInfoKey{
+ _ImageInfoKey(uint8_t i, uint8_t t) : index(i), type(t) {};
struct {
uint8_t index; /*! the allocated image index */
uint8_t type; /*! the information type */
GBE_ASSERT(AI != AE); const ir::Register surfaceReg = this->getRegister(*AI); ++AI;
const ir::Register reg = this->getRegister(&I, 0);
int infoType = it->second - GEN_OCL_GET_IMAGE_WIDTH;
-
const uint8_t surfaceID = ctx.getFunction().getImageSet()->getIdx(surfaceReg);
- ctx.GET_IMAGE_INFO(infoType, reg, surfaceID, ctx.reg(ir::FAMILY_DWORD));
+ ir::ImageInfoKey key(surfaceID, infoType);
+ const ir::Register infoReg = ctx.getFunction().getImageSet()->appendInfo(key, &ctx);
+ ctx.GET_IMAGE_INFO(infoType, reg, surfaceID, infoReg);
break;
}
case GEN_OCL_GET_SAMPLER_INFO: