forked from OSchip/llvm-project
Update style/clang-format (NFC).
Update to be consistent & so that future save + clang-format workflows don't introduce extra changes. PiperOrigin-RevId: 259361174
This commit is contained in:
parent
83c97a6784
commit
772930f8c6
|
@ -18,9 +18,9 @@
|
||||||
#ifndef LINALG1_OPS_H_
|
#ifndef LINALG1_OPS_H_
|
||||||
#define LINALG1_OPS_H_
|
#define LINALG1_OPS_H_
|
||||||
|
|
||||||
#include "linalg1/Types.h"
|
|
||||||
#include "linalg1/RangeOp.h"
|
#include "linalg1/RangeOp.h"
|
||||||
#include "linalg1/SliceOp.h"
|
#include "linalg1/SliceOp.h"
|
||||||
|
#include "linalg1/Types.h"
|
||||||
#include "linalg1/ViewOp.h"
|
#include "linalg1/ViewOp.h"
|
||||||
|
|
||||||
#endif // LINALG1_OPS_H_
|
#endif // LINALG1_OPS_H_
|
||||||
|
|
|
@ -36,14 +36,15 @@ namespace quantizer {
|
||||||
/// methods:
|
/// methods:
|
||||||
/// - addValueIdentityOp
|
/// - addValueIdentityOp
|
||||||
class FxpMathTargetConfig : public TargetConfiguration {
|
class FxpMathTargetConfig : public TargetConfiguration {
|
||||||
public:
|
public:
|
||||||
/// Creates an FxpMathTargetConfig instance which can be further customized.
|
/// Creates an FxpMathTargetConfig instance which can be further customized.
|
||||||
static std::unique_ptr<FxpMathTargetConfig> create(SolverContext &context);
|
static std::unique_ptr<FxpMathTargetConfig> create(SolverContext &context);
|
||||||
protected:
|
|
||||||
|
protected:
|
||||||
FxpMathTargetConfig(SolverContext &context) : TargetConfiguration(context) {}
|
FxpMathTargetConfig(SolverContext &context) : TargetConfiguration(context) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace quantizer
|
} // namespace quantizer
|
||||||
} // namespace mlir
|
} // namespace mlir
|
||||||
|
|
||||||
#endif // MLIR_QUANTIZER_CONFIGURATIONS_FXPMATHCONFIG_H
|
#endif // MLIR_QUANTIZER_CONFIGURATIONS_FXPMATHCONFIG_H
|
||||||
|
|
|
@ -88,7 +88,6 @@ static void populatePassManagers(llvm::legacy::PassManager &modulePM,
|
||||||
std::function<llvm::Error(llvm::Module *)>
|
std::function<llvm::Error(llvm::Module *)>
|
||||||
mlir::makeOptimizingTransformer(unsigned optLevel, unsigned sizeLevel) {
|
mlir::makeOptimizingTransformer(unsigned optLevel, unsigned sizeLevel) {
|
||||||
return [optLevel, sizeLevel](llvm::Module *m) -> llvm::Error {
|
return [optLevel, sizeLevel](llvm::Module *m) -> llvm::Error {
|
||||||
|
|
||||||
llvm::legacy::PassManager modulePM;
|
llvm::legacy::PassManager modulePM;
|
||||||
llvm::legacy::FunctionPassManager funcPM(m);
|
llvm::legacy::FunctionPassManager funcPM(m);
|
||||||
populatePassManagers(modulePM, funcPM, optLevel, sizeLevel);
|
populatePassManagers(modulePM, funcPM, optLevel, sizeLevel);
|
||||||
|
|
|
@ -637,12 +637,12 @@ void SimpleAffineExprFlattener::visitAddExpr(AffineBinaryOpExpr expr) {
|
||||||
operandExprStack.pop_back();
|
operandExprStack.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// t = expr mod c <=> t = expr - c*q and c*q <= expr <= c*q + c - 1
|
// t = expr mod c <=> t = expr - c*q and c*q <= expr <= c*q + c - 1
|
||||||
//
|
//
|
||||||
// A mod expression "expr mod c" is thus flattened by introducing a new local
|
// A mod expression "expr mod c" is thus flattened by introducing a new local
|
||||||
// variable q (= expr floordiv c), such that expr mod c is replaced with
|
// variable q (= expr floordiv c), such that expr mod c is replaced with
|
||||||
// 'expr - c * q' and c * q <= expr <= c * q + c - 1 are added to localVarCst.
|
// 'expr - c * q' and c * q <= expr <= c * q + c - 1 are added to localVarCst.
|
||||||
void SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
|
void SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
|
||||||
assert(operandExprStack.size() >= 2);
|
assert(operandExprStack.size() >= 2);
|
||||||
// This is a pure affine expr; the RHS will be a constant.
|
// This is a pure affine expr; the RHS will be a constant.
|
||||||
|
@ -723,14 +723,14 @@ void SimpleAffineExprFlattener::visitConstantExpr(AffineConstantExpr expr) {
|
||||||
eq[getConstantIndex()] = expr.getValue();
|
eq[getConstantIndex()] = expr.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// t = expr floordiv c <=> t = q, c * q <= expr <= c * q + c - 1
|
// t = expr floordiv c <=> t = q, c * q <= expr <= c * q + c - 1
|
||||||
// A floordiv is thus flattened by introducing a new local variable q, and
|
// A floordiv is thus flattened by introducing a new local variable q, and
|
||||||
// replacing that expression with 'q' while adding the constraints
|
// replacing that expression with 'q' while adding the constraints
|
||||||
// c * q <= expr <= c * q + c - 1 to localVarCst (done by
|
// c * q <= expr <= c * q + c - 1 to localVarCst (done by
|
||||||
// FlatAffineConstraints::addLocalFloorDiv).
|
// FlatAffineConstraints::addLocalFloorDiv).
|
||||||
//
|
//
|
||||||
// A ceildiv is similarly flattened:
|
// A ceildiv is similarly flattened:
|
||||||
// t = expr ceildiv c <=> t = (expr + c - 1) floordiv c
|
// t = expr ceildiv c <=> t = (expr + c - 1) floordiv c
|
||||||
void SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
|
void SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
|
||||||
bool isCeil) {
|
bool isCeil) {
|
||||||
assert(operandExprStack.size() >= 2);
|
assert(operandExprStack.size() >= 2);
|
||||||
|
@ -790,11 +790,11 @@ void SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
|
||||||
lhs[getLocalVarStartIndex() + loc] = 1;
|
lhs[getLocalVarStartIndex() + loc] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a local identifier (needed to flatten a mod, floordiv, ceildiv expr).
|
// Add a local identifier (needed to flatten a mod, floordiv, ceildiv expr).
|
||||||
// The local identifier added is always a floordiv of a pure add/mul affine
|
// The local identifier added is always a floordiv of a pure add/mul affine
|
||||||
// function of other identifiers, coefficients of which are specified in
|
// function of other identifiers, coefficients of which are specified in
|
||||||
// dividend and with respect to a positive constant divisor. localExpr is the
|
// dividend and with respect to a positive constant divisor. localExpr is the
|
||||||
// simplified tree expression (AffineExpr) corresponding to the quantifier.
|
// simplified tree expression (AffineExpr) corresponding to the quantifier.
|
||||||
void SimpleAffineExprFlattener::addLocalFloorDivId(ArrayRef<int64_t> dividend,
|
void SimpleAffineExprFlattener::addLocalFloorDivId(ArrayRef<int64_t> dividend,
|
||||||
int64_t divisor,
|
int64_t divisor,
|
||||||
AffineExpr localExpr) {
|
AffineExpr localExpr) {
|
||||||
|
|
|
@ -98,26 +98,37 @@ Token Lexer::lexToken() {
|
||||||
case 0:
|
case 0:
|
||||||
// This may either be a nul character in the source file or may be the EOF
|
// This may either be a nul character in the source file or may be the EOF
|
||||||
// marker that llvm::MemoryBuffer guarantees will be there.
|
// marker that llvm::MemoryBuffer guarantees will be there.
|
||||||
if (curPtr-1 == curBuffer.end())
|
if (curPtr - 1 == curBuffer.end())
|
||||||
return formToken(Token::eof, tokStart);
|
return formToken(Token::eof, tokStart);
|
||||||
|
|
||||||
LLVM_FALLTHROUGH;
|
LLVM_FALLTHROUGH;
|
||||||
case ':': return formToken(Token::colon, tokStart);
|
case ':':
|
||||||
case ',': return formToken(Token::comma, tokStart);
|
return formToken(Token::colon, tokStart);
|
||||||
case '(': return formToken(Token::l_paren, tokStart);
|
case ',':
|
||||||
case ')': return formToken(Token::r_paren, tokStart);
|
return formToken(Token::comma, tokStart);
|
||||||
case '{': return formToken(Token::l_brace, tokStart);
|
case '(':
|
||||||
case '}': return formToken(Token::r_brace, tokStart);
|
return formToken(Token::l_paren, tokStart);
|
||||||
|
case ')':
|
||||||
|
return formToken(Token::r_paren, tokStart);
|
||||||
|
case '{':
|
||||||
|
return formToken(Token::l_brace, tokStart);
|
||||||
|
case '}':
|
||||||
|
return formToken(Token::r_brace, tokStart);
|
||||||
case '[':
|
case '[':
|
||||||
return formToken(Token::l_square, tokStart);
|
return formToken(Token::l_square, tokStart);
|
||||||
case ']':
|
case ']':
|
||||||
return formToken(Token::r_square, tokStart);
|
return formToken(Token::r_square, tokStart);
|
||||||
case '<': return formToken(Token::less, tokStart);
|
case '<':
|
||||||
case '>': return formToken(Token::greater, tokStart);
|
return formToken(Token::less, tokStart);
|
||||||
case '=': return formToken(Token::equal, tokStart);
|
case '>':
|
||||||
|
return formToken(Token::greater, tokStart);
|
||||||
|
case '=':
|
||||||
|
return formToken(Token::equal, tokStart);
|
||||||
|
|
||||||
case '+': return formToken(Token::plus, tokStart);
|
case '+':
|
||||||
case '*': return formToken(Token::star, tokStart);
|
return formToken(Token::plus, tokStart);
|
||||||
|
case '*':
|
||||||
|
return formToken(Token::star, tokStart);
|
||||||
case '-':
|
case '-':
|
||||||
if (*curPtr == '>') {
|
if (*curPtr == '>') {
|
||||||
++curPtr;
|
++curPtr;
|
||||||
|
@ -144,10 +155,19 @@ Token Lexer::lexToken() {
|
||||||
LLVM_FALLTHROUGH;
|
LLVM_FALLTHROUGH;
|
||||||
case '%':
|
case '%':
|
||||||
return lexPrefixedIdentifier(tokStart);
|
return lexPrefixedIdentifier(tokStart);
|
||||||
case '"': return lexString(tokStart);
|
case '"':
|
||||||
|
return lexString(tokStart);
|
||||||
|
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case '0':
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
return lexNumber(tokStart);
|
return lexNumber(tokStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +189,7 @@ Token Lexer::lexComment() {
|
||||||
return lexToken();
|
return lexToken();
|
||||||
case 0:
|
case 0:
|
||||||
// If this is the end of the buffer, end the comment.
|
// If this is the end of the buffer, end the comment.
|
||||||
if (curPtr-1 == curBuffer.end()) {
|
if (curPtr - 1 == curBuffer.end()) {
|
||||||
--curPtr;
|
--curPtr;
|
||||||
return lexToken();
|
return lexToken();
|
||||||
}
|
}
|
||||||
|
@ -193,7 +213,7 @@ Token Lexer::lexBareIdentifierOrKeyword(const char *tokStart) {
|
||||||
++curPtr;
|
++curPtr;
|
||||||
|
|
||||||
// Check to see if this identifier is a keyword.
|
// Check to see if this identifier is a keyword.
|
||||||
StringRef spelling(tokStart, curPtr-tokStart);
|
StringRef spelling(tokStart, curPtr - tokStart);
|
||||||
|
|
||||||
// Check for i123.
|
// Check for i123.
|
||||||
if (tokStart[0] == 'i') {
|
if (tokStart[0] == 'i') {
|
||||||
|
@ -205,10 +225,9 @@ Token Lexer::lexBareIdentifierOrKeyword(const char *tokStart) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Token::Kind kind = llvm::StringSwitch<Token::Kind>(spelling)
|
Token::Kind kind = llvm::StringSwitch<Token::Kind>(spelling)
|
||||||
#define TOK_KEYWORD(SPELLING) \
|
#define TOK_KEYWORD(SPELLING) .Case(#SPELLING, Token::kw_##SPELLING)
|
||||||
.Case(#SPELLING, Token::kw_##SPELLING)
|
|
||||||
#include "TokenKinds.def"
|
#include "TokenKinds.def"
|
||||||
.Default(Token::bare_identifier);
|
.Default(Token::bare_identifier);
|
||||||
|
|
||||||
return Token(kind, spelling);
|
return Token(kind, spelling);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +288,7 @@ Token Lexer::lexPrefixedIdentifier(const char *tokStart) {
|
||||||
++curPtr;
|
++curPtr;
|
||||||
}
|
}
|
||||||
} else if (isalpha(*curPtr) || isPunct(*curPtr)) {
|
} else if (isalpha(*curPtr) || isPunct(*curPtr)) {
|
||||||
do {
|
do {
|
||||||
++curPtr;
|
++curPtr;
|
||||||
} while (isalpha(*curPtr) || isdigit(*curPtr) || isPunct(*curPtr));
|
} while (isalpha(*curPtr) || isdigit(*curPtr) || isPunct(*curPtr));
|
||||||
} else {
|
} else {
|
||||||
|
@ -310,14 +329,16 @@ Token Lexer::lexNumber(const char *tokStart) {
|
||||||
++curPtr;
|
++curPtr;
|
||||||
|
|
||||||
// Skip over [0-9]*([eE][-+]?[0-9]+)?
|
// Skip over [0-9]*([eE][-+]?[0-9]+)?
|
||||||
while (isdigit(*curPtr)) ++curPtr;
|
while (isdigit(*curPtr))
|
||||||
|
++curPtr;
|
||||||
|
|
||||||
if (*curPtr == 'e' || *curPtr == 'E') {
|
if (*curPtr == 'e' || *curPtr == 'E') {
|
||||||
if (isdigit(static_cast<unsigned char>(curPtr[1])) ||
|
if (isdigit(static_cast<unsigned char>(curPtr[1])) ||
|
||||||
((curPtr[1] == '-' || curPtr[1] == '+') &&
|
((curPtr[1] == '-' || curPtr[1] == '+') &&
|
||||||
isdigit(static_cast<unsigned char>(curPtr[2])))) {
|
isdigit(static_cast<unsigned char>(curPtr[2])))) {
|
||||||
curPtr += 2;
|
curPtr += 2;
|
||||||
while (isdigit(*curPtr)) ++curPtr;
|
while (isdigit(*curPtr))
|
||||||
|
++curPtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return formToken(Token::floatliteral, tokStart);
|
return formToken(Token::floatliteral, tokStart);
|
||||||
|
@ -338,13 +359,13 @@ Token Lexer::lexString(const char *tokStart) {
|
||||||
case 0:
|
case 0:
|
||||||
// If this is a random nul character in the middle of a string, just
|
// If this is a random nul character in the middle of a string, just
|
||||||
// include it. If it is the end of file, then it is an error.
|
// include it. If it is the end of file, then it is an error.
|
||||||
if (curPtr-1 != curBuffer.end())
|
if (curPtr - 1 != curBuffer.end())
|
||||||
continue;
|
continue;
|
||||||
LLVM_FALLTHROUGH;
|
LLVM_FALLTHROUGH;
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\v':
|
case '\v':
|
||||||
case '\f':
|
case '\f':
|
||||||
return emitError(curPtr-1, "expected '\"' in string literal");
|
return emitError(curPtr - 1, "expected '\"' in string literal");
|
||||||
case '\\':
|
case '\\':
|
||||||
// Handle explicitly a few escapes.
|
// Handle explicitly a few escapes.
|
||||||
if (*curPtr == '"' || *curPtr == '\\' || *curPtr == 'n' || *curPtr == 't')
|
if (*curPtr == '"' || *curPtr == '\\' || *curPtr == 'n' || *curPtr == 't')
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#ifndef MLIR_LIB_PARSER_LEXER_H
|
#ifndef MLIR_LIB_PARSER_LEXER_H
|
||||||
#define MLIR_LIB_PARSER_LEXER_H
|
#define MLIR_LIB_PARSER_LEXER_H
|
||||||
|
|
||||||
#include "mlir/Parser.h"
|
|
||||||
#include "Token.h"
|
#include "Token.h"
|
||||||
|
#include "mlir/Parser.h"
|
||||||
|
|
||||||
namespace mlir {
|
namespace mlir {
|
||||||
class Location;
|
class Location;
|
||||||
|
@ -48,7 +48,7 @@ public:
|
||||||
private:
|
private:
|
||||||
// Helpers.
|
// Helpers.
|
||||||
Token formToken(Token::Kind kind, const char *tokStart) {
|
Token formToken(Token::Kind kind, const char *tokStart) {
|
||||||
return Token(kind, StringRef(tokStart, curPtr-tokStart));
|
return Token(kind, StringRef(tokStart, curPtr - tokStart));
|
||||||
}
|
}
|
||||||
|
|
||||||
Token emitError(const char *loc, const Twine &message);
|
Token emitError(const char *loc, const Twine &message);
|
||||||
|
@ -73,4 +73,4 @@ private:
|
||||||
|
|
||||||
} // end namespace mlir
|
} // end namespace mlir
|
||||||
|
|
||||||
#endif // MLIR_LIB_PARSER_LEXER_H
|
#endif // MLIR_LIB_PARSER_LEXER_H
|
||||||
|
|
|
@ -25,17 +25,13 @@ using namespace mlir;
|
||||||
using llvm::SMLoc;
|
using llvm::SMLoc;
|
||||||
using llvm::SMRange;
|
using llvm::SMRange;
|
||||||
|
|
||||||
SMLoc Token::getLoc() const {
|
SMLoc Token::getLoc() const { return SMLoc::getFromPointer(spelling.data()); }
|
||||||
return SMLoc::getFromPointer(spelling.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
SMLoc Token::getEndLoc() const {
|
SMLoc Token::getEndLoc() const {
|
||||||
return SMLoc::getFromPointer(spelling.data() + spelling.size());
|
return SMLoc::getFromPointer(spelling.data() + spelling.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
SMRange Token::getLocRange() const {
|
SMRange Token::getLocRange() const { return SMRange(getLoc(), getEndLoc()); }
|
||||||
return SMRange(getLoc(), getEndLoc());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// For an integer token, return its value as an unsigned. If it doesn't fit,
|
/// For an integer token, return its value as an unsigned. If it doesn't fit,
|
||||||
/// return None.
|
/// return None.
|
||||||
|
@ -71,8 +67,8 @@ Optional<double> Token::getFloatingPointValue() const {
|
||||||
/// For an inttype token, return its bitwidth.
|
/// For an inttype token, return its bitwidth.
|
||||||
Optional<unsigned> Token::getIntTypeBitwidth() const {
|
Optional<unsigned> Token::getIntTypeBitwidth() const {
|
||||||
unsigned result = 0;
|
unsigned result = 0;
|
||||||
if (spelling[1] == '0' ||
|
if (spelling[1] == '0' || spelling.drop_front().getAsInteger(10, result) ||
|
||||||
spelling.drop_front().getAsInteger(10, result) || result == 0)
|
result == 0)
|
||||||
return None;
|
return None;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -137,10 +133,17 @@ Optional<unsigned> Token::getHashIdentifierNumber() const {
|
||||||
/// literal tokens since they have no fixed spelling.
|
/// literal tokens since they have no fixed spelling.
|
||||||
StringRef Token::getTokenSpelling(Kind kind) {
|
StringRef Token::getTokenSpelling(Kind kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
default: llvm_unreachable("This token kind has no fixed spelling");
|
default:
|
||||||
#define TOK_PUNCTUATION(NAME, SPELLING) case NAME: return SPELLING;
|
llvm_unreachable("This token kind has no fixed spelling");
|
||||||
#define TOK_OPERATOR(NAME, SPELLING) case NAME: return SPELLING;
|
#define TOK_PUNCTUATION(NAME, SPELLING) \
|
||||||
#define TOK_KEYWORD(SPELLING) case kw_##SPELLING: return #SPELLING;
|
case NAME: \
|
||||||
|
return SPELLING;
|
||||||
|
#define TOK_OPERATOR(NAME, SPELLING) \
|
||||||
|
case NAME: \
|
||||||
|
return SPELLING;
|
||||||
|
#define TOK_KEYWORD(SPELLING) \
|
||||||
|
case kw_##SPELLING: \
|
||||||
|
return #SPELLING;
|
||||||
#include "TokenKinds.def"
|
#include "TokenKinds.def"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,8 +151,11 @@ StringRef Token::getTokenSpelling(Kind kind) {
|
||||||
/// Return true if this is one of the keyword token kinds (e.g. kw_if).
|
/// Return true if this is one of the keyword token kinds (e.g. kw_if).
|
||||||
bool Token::isKeyword() const {
|
bool Token::isKeyword() const {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
default: return false;
|
default:
|
||||||
#define TOK_KEYWORD(SPELLING) case kw_##SPELLING: return true;
|
return false;
|
||||||
|
#define TOK_KEYWORD(SPELLING) \
|
||||||
|
case kw_##SPELLING: \
|
||||||
|
return true;
|
||||||
#include "TokenKinds.def"
|
#include "TokenKinds.def"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,7 @@ public:
|
||||||
#include "TokenKinds.def"
|
#include "TokenKinds.def"
|
||||||
};
|
};
|
||||||
|
|
||||||
Token(Kind kind, StringRef spelling)
|
Token(Kind kind, StringRef spelling) : kind(kind), spelling(spelling) {}
|
||||||
: kind(kind), spelling(spelling) {}
|
|
||||||
|
|
||||||
// Return the bytes that make up this token.
|
// Return the bytes that make up this token.
|
||||||
StringRef getSpelling() const { return spelling; }
|
StringRef getSpelling() const { return spelling; }
|
||||||
|
@ -47,12 +46,10 @@ public:
|
||||||
Kind getKind() const { return kind; }
|
Kind getKind() const { return kind; }
|
||||||
bool is(Kind K) const { return kind == K; }
|
bool is(Kind K) const { return kind == K; }
|
||||||
|
|
||||||
bool isAny(Kind k1, Kind k2) const {
|
bool isAny(Kind k1, Kind k2) const { return is(k1) || is(k2); }
|
||||||
return is(k1) || is(k2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return true if this token is one of the specified kinds.
|
/// Return true if this token is one of the specified kinds.
|
||||||
template <typename ...T>
|
template <typename... T>
|
||||||
bool isAny(Kind k1, Kind k2, Kind k3, T... others) const {
|
bool isAny(Kind k1, Kind k2, Kind k3, T... others) const {
|
||||||
if (is(k1))
|
if (is(k1))
|
||||||
return true;
|
return true;
|
||||||
|
@ -62,8 +59,7 @@ public:
|
||||||
bool isNot(Kind k) const { return kind != k; }
|
bool isNot(Kind k) const { return kind != k; }
|
||||||
|
|
||||||
/// Return true if this token isn't one of the specified kinds.
|
/// Return true if this token isn't one of the specified kinds.
|
||||||
template <typename ...T>
|
template <typename... T> bool isNot(Kind k1, Kind k2, T... others) const {
|
||||||
bool isNot(Kind k1, Kind k2, T... others) const {
|
|
||||||
return !isAny(k1, k2, others...);
|
return !isAny(k1, k2, others...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +97,6 @@ public:
|
||||||
llvm::SMLoc getEndLoc() const;
|
llvm::SMLoc getEndLoc() const;
|
||||||
llvm::SMRange getLocRange() const;
|
llvm::SMRange getLocRange() const;
|
||||||
|
|
||||||
|
|
||||||
/// Given a punctuation or keyword token kind, return the spelling of the
|
/// Given a punctuation or keyword token kind, return the spelling of the
|
||||||
/// token as a string. Warning: This will abort on markers, identifiers and
|
/// token as a string. Warning: This will abort on markers, identifiers and
|
||||||
/// literal tokens since they have no fixed spelling.
|
/// literal tokens since they have no fixed spelling.
|
||||||
|
@ -118,4 +113,4 @@ private:
|
||||||
|
|
||||||
} // end namespace mlir
|
} // end namespace mlir
|
||||||
|
|
||||||
#endif // MLIR_LIB_PARSER_TOKEN_H
|
#endif // MLIR_LIB_PARSER_TOKEN_H
|
||||||
|
|
Loading…
Reference in New Issue