summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Parser/Token.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@google.com>2018-06-29 22:08:05 -0700
committerjpienaar <jpienaar@google.com>2019-03-29 12:27:32 -0700
commit6af866c58d21813fb243906611d02bb2a8ffa43a (patch)
tree08d3cd7dd82e4c3781b07c447ee9164ab0c8037c /mlir/lib/Parser/Token.cpp
parentfdf7bc4e25a8f1f35aba0c32bb5cef9d7ea3c949 (diff)
downloadbcm5719-llvm-6af866c58d21813fb243906611d02bb2a8ffa43a.tar.gz
bcm5719-llvm-6af866c58d21813fb243906611d02bb2a8ffa43a.zip
Enhance the type system to support arbitrary precision integers, which are
important for low-bitwidth inference cases and hardware synthesis targets. Rename 'int' to 'affineint' to avoid confusion between "the integers" and "the int type". PiperOrigin-RevId: 202751508
Diffstat (limited to 'mlir/lib/Parser/Token.cpp')
-rw-r--r--mlir/lib/Parser/Token.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp
index 5563255b444..e1e4bedf28f 100644
--- a/mlir/lib/Parser/Token.cpp
+++ b/mlir/lib/Parser/Token.cpp
@@ -48,6 +48,18 @@ Optional<unsigned> Token::getUnsignedIntegerValue() const {
return result;
}
+/// For an inttype token, return its bitwidth.
+Optional<unsigned> Token::getIntTypeBitwidth() const {
+ unsigned result = 0;
+ if (spelling[1] == '0' ||
+ spelling.drop_front().getAsInteger(10, result) ||
+ // Arbitrary but large limit on bitwidth.
+ result > 4096 || result == 0)
+ return None;
+ return result;
+}
+
+
/// Given a 'string' token, return its value, including removing the quote
/// characters and unescaping the contents of the string.
std::string Token::getStringValue() const {
OpenPOWER on IntegriCloud