Instruction* import = new Instruction(getUniqueId(), NoType, OpExtInstImport);
import->addStringOperand(name);
- imports.push_back(import);
+ imports.push_back(std::unique_ptr<Instruction>(import));
return import->getResultId();
}
if (groupedTypes[OpTypeVoid].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeVoid);
groupedTypes[OpTypeVoid].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else
type = groupedTypes[OpTypeVoid].back();
if (groupedTypes[OpTypeBool].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeBool);
groupedTypes[OpTypeBool].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else
type = groupedTypes[OpTypeBool].back();
if (groupedTypes[OpTypeSampler].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeSampler);
groupedTypes[OpTypeSampler].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else
type = groupedTypes[OpTypeSampler].back();
type->addImmediateOperand(storageClass);
type->addIdOperand(pointee);
groupedTypes[OpTypePointer].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
type->addImmediateOperand(width);
type->addImmediateOperand(hasSign ? 1 : 0);
groupedTypes[OpTypeInt].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
type = new Instruction(getUniqueId(), NoType, OpTypeFloat);
type->addImmediateOperand(width);
groupedTypes[OpTypeFloat].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
for (int op = 0; op < (int)members.size(); ++op)
type->addIdOperand(members[op]);
groupedTypes[OpTypeStruct].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
addName(type->getResultId(), name);
type->addIdOperand(component);
type->addImmediateOperand(size);
groupedTypes[OpTypeVector].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
type->addIdOperand(column);
type->addImmediateOperand(cols);
groupedTypes[OpTypeMatrix].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
type->addIdOperand(element);
type->addIdOperand(sizeId);
groupedTypes[OpTypeArray].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
{
Instruction* type = new Instruction(getUniqueId(), NoType, OpTypeRuntimeArray);
type->addIdOperand(element);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
for (int p = 0; p < (int)paramTypes.size(); ++p)
type->addIdOperand(paramTypes[p]);
groupedTypes[OpTypeFunction].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
type->addImmediateOperand((unsigned int)format);
groupedTypes[OpTypeImage].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
type->addIdOperand(imageType);
groupedTypes[OpTypeSampledImage].push_back(type);
- constantsTypesGlobals.push_back(type);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
return type->getResultId();
// Make it
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
- constantsTypesGlobals.push_back(c);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeBool].push_back(c);
module.mapInstruction(c);
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->addImmediateOperand(value);
- constantsTypesGlobals.push_back(c);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeInt].push_back(c);
module.mapInstruction(c);
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->addImmediateOperand(value);
- constantsTypesGlobals.push_back(c);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeFloat].push_back(c);
module.mapInstruction(c);
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
c->addImmediateOperand(op1);
c->addImmediateOperand(op2);
- constantsTypesGlobals.push_back(c);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[OpTypeFloat].push_back(c);
module.mapInstruction(c);
Instruction* c = new Instruction(getUniqueId(), typeId, OpConstantComposite);
for (int op = 0; op < (int)members.size(); ++op)
c->addIdOperand(members[op]);
- constantsTypesGlobals.push_back(c);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[typeClass].push_back(c);
module.mapInstruction(c);
entryPoint->addIdOperand(function->getId());
entryPoint->addStringOperand(name);
- entryPoints.push_back(entryPoint);
+ entryPoints.push_back(std::unique_ptr<Instruction>(entryPoint));
return entryPoint;
}
if (value3 >= 0)
instr->addImmediateOperand(value3);
- executionModes.push_back(instr);
+ executionModes.push_back(std::unique_ptr<Instruction>(instr));
}
void Builder::addName(Id id, const char* string)
name->addIdOperand(id);
name->addStringOperand(string);
- names.push_back(name);
+ names.push_back(std::unique_ptr<Instruction>(name));
}
void Builder::addMemberName(Id id, int memberNumber, const char* string)
name->addImmediateOperand(memberNumber);
name->addStringOperand(string);
- names.push_back(name);
+ names.push_back(std::unique_ptr<Instruction>(name));
}
void Builder::addLine(Id target, Id fileName, int lineNum, int column)
line->addImmediateOperand(lineNum);
line->addImmediateOperand(column);
- lines.push_back(line);
+ lines.push_back(std::unique_ptr<Instruction>(line));
}
void Builder::addDecoration(Id id, Decoration decoration, int num)
if (num >= 0)
dec->addImmediateOperand(num);
- decorations.push_back(dec);
+ decorations.push_back(std::unique_ptr<Instruction>(dec));
}
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, int num)
if (num >= 0)
dec->addImmediateOperand(num);
- decorations.push_back(dec);
+ decorations.push_back(std::unique_ptr<Instruction>(dec));
}
// Comments in header
if (name)
addName(function->getId(), name);
+ functions.push_back(std::unique_ptr<Function>(function));
+
return function;
}
if (retVal) {
Instruction* inst = new Instruction(NoResult, NoType, OpReturnValue);
inst->addIdOperand(retVal);
- buildPoint->addInstruction(inst);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(inst));
} else
- buildPoint->addInstruction(new Instruction(NoResult, NoType, OpReturn));
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(new Instruction(NoResult, NoType, OpReturn)));
if (! implicit)
createAndSetNoPredecessorBlock("post-return");
// Comments in header
void Builder::makeDiscard()
{
- buildPoint->addInstruction(new Instruction(OpKill));
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(new Instruction(OpKill)));
createAndSetNoPredecessorBlock("post-discard");
}
switch (storageClass) {
case StorageClassFunction:
// Validation rules require the declaration in the entry block
- buildPoint->getParent().addLocalVariable(inst);
+ buildPoint->getParent().addLocalVariable(std::unique_ptr<Instruction>(inst));
break;
default:
- constantsTypesGlobals.push_back(inst);
+ constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(inst));
module.mapInstruction(inst);
break;
}
Id Builder::createUndefined(Id type)
{
Instruction* inst = new Instruction(getUniqueId(), type, OpUndef);
- buildPoint->addInstruction(inst);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(inst));
return inst->getResultId();
}
Instruction* store = new Instruction(OpStore);
store->addIdOperand(lValue);
store->addIdOperand(rValue);
- buildPoint->addInstruction(store);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(store));
}
// Comments in header
{
Instruction* load = new Instruction(getUniqueId(), getDerefTypeId(lValue), OpLoad);
load->addIdOperand(lValue);
- buildPoint->addInstruction(load);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(load));
return load->getResultId();
}
chain->addIdOperand(base);
for (int i = 0; i < (int)offsets.size(); ++i)
chain->addIdOperand(offsets[i]);
- buildPoint->addInstruction(chain);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(chain));
return chain->getResultId();
}
Instruction* length = new Instruction(getUniqueId(), makeIntType(32), OpArrayLength);
length->addIdOperand(base);
length->addImmediateOperand(member);
- buildPoint->addInstruction(length);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(length));
return length->getResultId();
}
Instruction* extract = new Instruction(getUniqueId(), typeId, OpCompositeExtract);
extract->addIdOperand(composite);
extract->addImmediateOperand(index);
- buildPoint->addInstruction(extract);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(extract));
return extract->getResultId();
}
extract->addIdOperand(composite);
for (int i = 0; i < (int)indexes.size(); ++i)
extract->addImmediateOperand(indexes[i]);
- buildPoint->addInstruction(extract);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(extract));
return extract->getResultId();
}
insert->addIdOperand(object);
insert->addIdOperand(composite);
insert->addImmediateOperand(index);
- buildPoint->addInstruction(insert);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(insert));
return insert->getResultId();
}
insert->addIdOperand(composite);
for (int i = 0; i < (int)indexes.size(); ++i)
insert->addImmediateOperand(indexes[i]);
- buildPoint->addInstruction(insert);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(insert));
return insert->getResultId();
}
Instruction* extract = new Instruction(getUniqueId(), typeId, OpVectorExtractDynamic);
extract->addIdOperand(vector);
extract->addIdOperand(componentIndex);
- buildPoint->addInstruction(extract);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(extract));
return extract->getResultId();
}
insert->addIdOperand(vector);
insert->addIdOperand(component);
insert->addIdOperand(componentIndex);
- buildPoint->addInstruction(insert);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(insert));
return insert->getResultId();
}
void Builder::createNoResultOp(Op opCode)
{
Instruction* op = new Instruction(opCode);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operand, no result id, and no type
{
Instruction* op = new Instruction(opCode);
op->addIdOperand(operand);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operand, no result id, and no type
Instruction* op = new Instruction(opCode);
for (auto operand : operands)
op->addIdOperand(operand);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
void Builder::createControlBarrier(Scope execution, Scope memory, MemorySemanticsMask semantics)
op->addImmediateOperand(makeUintConstant(execution));
op->addImmediateOperand(makeUintConstant(memory));
op->addImmediateOperand(makeUintConstant(semantics));
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemantics)
Instruction* op = new Instruction(OpMemoryBarrier);
op->addImmediateOperand(makeUintConstant(executionScope));
op->addImmediateOperand(makeUintConstant(memorySemantics));
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operands, a result id, and a type
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(operand);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
op->addIdOperand(left);
op->addIdOperand(right);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
op->addIdOperand(op1);
op->addIdOperand(op2);
op->addIdOperand(op3);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
for (auto operand : operands)
op->addIdOperand(operand);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
op->addIdOperand(function->getId());
for (int a = 0; a < (int)args.size(); ++a)
op->addIdOperand(args[a]);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
swizzle->addIdOperand(source);
for (int i = 0; i < (int)channels.size(); ++i)
swizzle->addImmediateOperand(channels[i]);
- buildPoint->addInstruction(swizzle);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(swizzle));
return swizzle->getResultId();
}
// finish the instruction with these components selectors
for (int i = 0; i < numTargetComponents; ++i)
swizzle->addImmediateOperand(components[i]);
- buildPoint->addInstruction(swizzle);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(swizzle));
return swizzle->getResultId();
}
Instruction* smear = new Instruction(getUniqueId(), vectorType, OpCompositeConstruct);
for (int c = 0; c < numComponents; ++c)
smear->addIdOperand(scalar);
- buildPoint->addInstruction(smear);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(smear));
return smear->getResultId();
}
for (int arg = 0; arg < (int)args.size(); ++arg)
inst->addIdOperand(args[arg]);
- buildPoint->addInstruction(inst);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(inst));
return inst->getResultId();
}
for (int op = optArgNum + 1; op < numArgs; ++op)
textureInst->addIdOperand(texArgs[op]);
setPrecision(textureInst->getResultId(), precision);
- buildPoint->addInstruction(textureInst);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(textureInst));
Id resultId = textureInst->getResultId();
query->addIdOperand(parameters.coords);
if (parameters.lod)
query->addIdOperand(parameters.lod);
- buildPoint->addInstruction(query);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(query));
return query->getResultId();
}
Instruction* op = new Instruction(getUniqueId(), typeId, OpCompositeConstruct);
for (int c = 0; c < (int)constituents.size(); ++c)
op->addIdOperand(constituents[c]);
- buildPoint->addInstruction(op);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
switchInst->addImmediateOperand(caseValues[i]);
switchInst->addIdOperand(segmentBlocks[valueIndexToSegment[i]]->getId());
}
- buildPoint->addInstruction(switchInst);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(switchInst));
// push the merge block
switchMerges.push(mergeBlock);
// but we don't yet know where they will come from.
loop.isFirstIteration->addIdOperand(makeBoolConstant(true));
loop.isFirstIteration->addIdOperand(preheader->getId());
- getBuildPoint()->addInstruction(loop.isFirstIteration);
+ getBuildPoint()->addInstruction(std::unique_ptr<Instruction>(loop.isFirstIteration));
// Mark the end of the structured loop. This must exist in the loop header block.
createLoopMerge(loop.merge, loop.header, LoopControlMaskNone);
{
Instruction* branch = new Instruction(OpBranch);
branch->addIdOperand(block->getId());
- buildPoint->addInstruction(branch);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(branch));
block->addPredecessor(buildPoint);
}
Instruction* merge = new Instruction(OpSelectionMerge);
merge->addIdOperand(mergeBlock->getId());
merge->addImmediateOperand(control);
- buildPoint->addInstruction(merge);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(merge));
}
void Builder::createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned int control)
merge->addIdOperand(mergeBlock->getId());
merge->addIdOperand(continueBlock->getId());
merge->addImmediateOperand(control);
- buildPoint->addInstruction(merge);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(merge));
}
void Builder::createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock)
branch->addIdOperand(condition);
branch->addIdOperand(thenBlock->getId());
branch->addIdOperand(elseBlock->getId());
- buildPoint->addInstruction(branch);
+ buildPoint->addInstruction(std::unique_ptr<Instruction>(branch));
thenBlock->addPredecessor(buildPoint);
elseBlock->addPredecessor(buildPoint);
}
-void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector<Instruction*>& instructions) const
+void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector<std::unique_ptr<Instruction> >& instructions) const
{
for (int i = 0; i < (int)instructions.size(); ++i) {
instructions[i]->dump(out);