Skip to content

Commit d1c08dd

Browse files
fix code review comments
Signed-off-by: Davide Grohmann <[email protected]> Change-Id: I7028dbe4bbcd644f82369785614b16d990a6f11c
1 parent 3fd3a22 commit d1c08dd

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ Value spirv::Deserializer::getValue(uint32_t id) {
9090
graphConstantARMInfo = getGraphConstantARM(id)) {
9191
IntegerAttr graphConstantID = graphConstantARMInfo->graphConstantID;
9292
Type resultType = graphConstantARMInfo->resultType;
93-
return opBuilder.create<spirv::GraphConstantARMOp>(unknownLoc, resultType,
94-
graphConstantID);
93+
return spirv::GraphConstantARMOp::create(opBuilder, unknownLoc, resultType,
94+
graphConstantID);
9595
}
9696
return valueMap.lookup(id);
9797
}

mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -677,20 +677,20 @@ spirv::Deserializer::processGraphEntryPointARM(ArrayRef<uint32_t> operands) {
677677
}
678678

679679
unsigned wordIndex = 0;
680-
uint32_t grID = operands[wordIndex++];
681-
if (!graphMap.count(grID)) {
680+
uint32_t graphID = operands[wordIndex++];
681+
if (!graphMap.contains(graphID)) {
682682
return emitError(unknownLoc,
683683
"missing graph definition/declaration with id ")
684-
<< grID;
684+
<< graphID;
685685
}
686686

687-
spirv::GraphARMOp graphARM = graphMap[grID];
687+
spirv::GraphARMOp graphARM = graphMap[graphID];
688688
StringRef name = decodeStringLiteral(operands, wordIndex);
689689
graphARM.setSymName(name);
690690
graphARM.setEntryPoint(true);
691691

692692
SmallVector<Attribute, 4> interface;
693-
for (int64_t size = operands.size(); wordIndex < size; wordIndex++) {
693+
for (int64_t size = operands.size(); wordIndex < size; ++wordIndex) {
694694
if (spirv::GlobalVariableOp arg = getGlobalVariable(operands[wordIndex])) {
695695
interface.push_back(SymbolRefAttr::get(arg.getOperation()));
696696
} else {
@@ -729,22 +729,22 @@ spirv::Deserializer::processGraphARM(ArrayRef<uint32_t> operands) {
729729
return emitError(unknownLoc, "expected at least one result");
730730
}
731731

732-
uint32_t grID = operands[1];
733-
if (graphMap.count(grID)) {
732+
uint32_t graphID = operands[1];
733+
if (graphMap.count(graphID)) {
734734
return emitError(unknownLoc, "duplicate graph definition/declaration");
735735
}
736736

737-
std::string grName = getGraphSymbol(grID);
737+
std::string graphName = getGraphSymbol(graphID);
738738
auto graphOp =
739-
opBuilder.create<spirv::GraphARMOp>(unknownLoc, grName, graphType);
740-
curGraph = graphMap[grID] = graphOp;
739+
opBuilder.create<spirv::GraphARMOp>(unknownLoc, graphName, graphType);
740+
curGraph = graphMap[graphID] = graphOp;
741741
Block *entryBlock = graphOp.addEntryBlock();
742742
LLVM_DEBUG({
743743
logger.startLine()
744744
<< "//===-------------------------------------------===//\n";
745-
logger.startLine() << "[graph] name: " << grName << "\n";
745+
logger.startLine() << "[graph] name: " << graphName << "\n";
746746
logger.startLine() << "[graph] type: " << graphType << "\n";
747-
logger.startLine() << "[graph] ID: " << grID << "\n";
747+
logger.startLine() << "[graph] ID: " << graphID << "\n";
748748
logger.startLine() << "[graph] entry block: " << entryBlock << "\n";
749749
logger.indent();
750750
});
@@ -795,8 +795,8 @@ spirv::Deserializer::processGraphARM(ArrayRef<uint32_t> operands) {
795795
// deserializing the body of this function.
796796
OpBuilder::InsertionGuard moduleInsertionGuard(opBuilder);
797797

798-
blockMap[grID] = entryBlock;
799-
if (failed(createGraphBlock(grID))) {
798+
blockMap[graphID] = entryBlock;
799+
if (failed(createGraphBlock(graphID))) {
800800
return failure();
801801
}
802802

@@ -1535,7 +1535,7 @@ spirv::Deserializer::processGraphTypeARM(ArrayRef<uint32_t> operands) {
15351535
uint32_t numInputs = operands[1];
15361536
SmallVector<Type, 1> argTypes;
15371537
SmallVector<Type, 1> returnTypes;
1538-
for (unsigned i = 2; i < size; i++) {
1538+
for (unsigned i = 2; i < size; ++i) {
15391539
Type inOutTy = getType(operands[i]);
15401540
if (!inOutTy) {
15411541
return emitError(unknownLoc,

mlir/lib/Target/SPIRV/Serialization/Serializer.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,20 +889,18 @@ Serializer::prepareGraphType(Location loc, GraphType type,
889889

890890
operands.push_back(type.getNumInputs());
891891

892-
for (const Type &res : type.getInputs()) {
892+
for (Type argType : type.getInputs()) {
893893
uint32_t argTypeID = 0;
894-
if (failed(processType(loc, res, argTypeID))) {
894+
if (failed(processType(loc, argType, argTypeID)))
895895
return failure();
896-
}
897896
operands.push_back(argTypeID);
898897
}
899898

900-
for (const Type &res : type.getResults()) {
901-
uint32_t resultID = 0;
902-
if (failed(processType(loc, res, resultID))) {
899+
for (Type resType : type.getResults()) {
900+
uint32_t resTypeID = 0;
901+
if (failed(processType(loc, resType, resTypeID)))
903902
return failure();
904-
}
905-
operands.push_back(resultID);
903+
operands.push_back(resTypeID);
906904
}
907905

908906
return success();

0 commit comments

Comments
 (0)