1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00
llvm-mirror/utils/TableGen/SDNodeProperties.cpp
Daniel Sanders cb73b0150f [tablegen] Add locations to many PrintFatalError() calls
Summary:
While working on the GISel Combiner, I noticed I was producing location-less
error messages fairly often and set about fixing this. In the process, I
noticed quite a few places elsewhere in TableGen that also neglected to include
a relevant location.

This patch adds locations to errors that relate to a specific record (or a
field within it) and also have easy access to the relevant location. This is
particularly useful when multiclasses are involved as many of these errors
refer to the full name of a record and it's difficult to guess which substring
is grep-able.

Unfortunately, tablegen currently only supports Record granularity so it's not
currently possible to point at a specific Init so these sometimes point at the
record that caused the error rather than the precise origin of the error.

Reviewers: bogner, aditya_nandakumar, volkan, aemerson, paquette, nhaehnle

Reviewed By: nhaehnle

Subscribers: jdoerfert, nhaehnle, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58077

llvm-svn: 353862
2019-02-12 17:36:57 +00:00

49 lines
1.9 KiB
C++

//===- SDNodeProperties.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "SDNodeProperties.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
using namespace llvm;
unsigned llvm::parseSDPatternOperatorProperties(Record *R) {
unsigned Properties = 0;
for (Record *Property : R->getValueAsListOfDefs("Properties")) {
if (Property->getName() == "SDNPCommutative") {
Properties |= 1 << SDNPCommutative;
} else if (Property->getName() == "SDNPAssociative") {
Properties |= 1 << SDNPAssociative;
} else if (Property->getName() == "SDNPHasChain") {
Properties |= 1 << SDNPHasChain;
} else if (Property->getName() == "SDNPOutGlue") {
Properties |= 1 << SDNPOutGlue;
} else if (Property->getName() == "SDNPInGlue") {
Properties |= 1 << SDNPInGlue;
} else if (Property->getName() == "SDNPOptInGlue") {
Properties |= 1 << SDNPOptInGlue;
} else if (Property->getName() == "SDNPMayStore") {
Properties |= 1 << SDNPMayStore;
} else if (Property->getName() == "SDNPMayLoad") {
Properties |= 1 << SDNPMayLoad;
} else if (Property->getName() == "SDNPSideEffect") {
Properties |= 1 << SDNPSideEffect;
} else if (Property->getName() == "SDNPMemOperand") {
Properties |= 1 << SDNPMemOperand;
} else if (Property->getName() == "SDNPVariadic") {
Properties |= 1 << SDNPVariadic;
} else {
PrintFatalError(R->getLoc(), "Unknown SD Node property '" +
Property->getName() + "' on node '" +
R->getName() + "'!");
}
}
return Properties;
}