[clang] 9773cad - [RISCV] Add additional checking to tablgen RISCVVEmitter requested in D95016.
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 10 19:56:25 PST 2021
Author: Craig Topper
Date: 2021-03-10T19:46:25-08:00
New Revision: 9773cad51939d3980d841876d77064eb7a11002f
URL: https://github.com/llvm/llvm-project/commit/9773cad51939d3980d841876d77064eb7a11002f
DIFF: https://github.com/llvm/llvm-project/commit/9773cad51939d3980d841876d77064eb7a11002f.diff
LOG: [RISCV] Add additional checking to tablgen RISCVVEmitter requested in D95016.
This errors, but doesn't give source location. We'd need to pass
the Record through several layers to get to the location.
Reviewed By: jrtc27
Differential Revision: https://reviews.llvm.org/D98379
Added:
Modified:
clang/utils/TableGen/RISCVVEmitter.cpp
Removed:
################################################################################
diff --git a/clang/utils/TableGen/RISCVVEmitter.cpp b/clang/utils/TableGen/RISCVVEmitter.cpp
index 3a84590c3a65..49574e45d5bd 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include <numeric>
@@ -536,7 +537,7 @@ void RVVType::applyBasicType() {
ScalarType = ScalarTypeKind::Float;
break;
default:
- llvm_unreachable("Unhandled type code!");
+ PrintFatalError("Unhandled type code!");
}
assert(ElementBitwidth != 0 && "Bad element bitwidth!");
}
@@ -587,7 +588,7 @@ void RVVType::applyModifier(StringRef Transformer) {
Scale = 0;
break;
default:
- llvm_unreachable("Illegal primitive type transformers!");
+ PrintFatalError("Illegal primitive type transformers!");
}
Transformer = Transformer.drop_back();
@@ -595,9 +596,15 @@ void RVVType::applyModifier(StringRef Transformer) {
for (char I : Transformer) {
switch (I) {
case 'P':
+ if (IsConstant)
+ PrintFatalError("'P' transformer cannot be used after 'C'");
+ if (IsPointer)
+ PrintFatalError("'P' transformer cannot be used twice");
IsPointer = true;
break;
case 'C':
+ if (IsConstant)
+ PrintFatalError("'C' transformer cannot be used twice");
IsConstant = true;
break;
case 'K':
@@ -614,11 +621,11 @@ void RVVType::applyModifier(StringRef Transformer) {
break;
case 'S':
LMUL = LMULType(0);
- // Update ElementBitwidth need ot update Scale too.
+ // Update ElementBitwidth need to update Scale too.
Scale = LMUL.getScale(ElementBitwidth);
break;
default:
- llvm_unreachable("Illegal non-primitive type transformer!");
+ PrintFatalError("Illegal non-primitive type transformer!");
}
}
}
More information about the cfe-commits
mailing list