diff options
| author | Sander de Smalen <sander.desmalen@arm.com> | 2018-04-26 12:54:42 +0000 |
|---|---|---|
| committer | Sander de Smalen <sander.desmalen@arm.com> | 2018-04-26 12:54:42 +0000 |
| commit | fe17a78b86d3cf1218a605601e15673f501d4f2b (patch) | |
| tree | 271944b9bb7b837e9c711332ef82c925b471bd0f /llvm/lib/Target | |
| parent | bd896472296edcff008f1e90c7926fc440b333ff (diff) | |
| download | bcm5719-llvm-fe17a78b86d3cf1218a605601e15673f501d4f2b.tar.gz bcm5719-llvm-fe17a78b86d3cf1218a605601e15673f501d4f2b.zip | |
[AArch64][SVE] Enable DiagnosticPredicates for SVE LD1 instructions.
This patch extends the PredicateMethod of AsmOperands used in SVE's
LD1 instructions with a DiagnosticPredicate. This makes them 'context
sensitive' to the operand that has been parsed and tells the user to
use the right register (with expected shift/extend), rather than telling
the immediate is out of range when it actually parsed a register.
Patch [2/2] in a series to improve assembler diagnostics for SVE:
- Patch [1/2]: https://reviews.llvm.org/D45879
- Patch [2/2]: https://reviews.llvm.org/D45880
Reviewers: olista01, stoklund, craig.topper, mcrosier, rengolin, echristo, fhahn, SjoerdMeijer, evandro, javed.absar
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D45880
llvm-svn: 330934
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 6af1207b580..2f042cd3df6 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -506,19 +506,24 @@ public: template <int Width> bool isSImm() const { return isSImmScaled<Width, 1>(); } - template <int Bits, int Scale> bool isSImmScaled() const { + template <int Bits, int Scale> + DiagnosticPredicate isSImmScaled() const { if (!isImm()) - return false; + return DiagnosticPredicateTy::NoMatch; + const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(getImm()); if (!MCE) - return false; + return DiagnosticPredicateTy::NoMatch; int64_t Shift = Bits - 1; int64_t MinVal = (int64_t(1) << Shift) * -Scale; int64_t MaxVal = ((int64_t(1) << Shift) - 1) * Scale; int64_t Val = MCE->getValue(); - return Val >= MinVal && Val <= MaxVal && (Val % Scale) == 0; + if (Val >= MinVal && Val <= MaxVal && (Val % Scale) == 0) + return DiagnosticPredicateTy::Match; + + return DiagnosticPredicateTy::NearMatch; } bool isSVEPattern() const { @@ -859,10 +864,16 @@ public: template <int ElementWidth, unsigned Class, AArch64_AM::ShiftExtendType ShiftExtendTy, int ShiftWidth> - bool isSVEVectorRegWithShiftExtend() const { - return Kind == k_Register && isSVEVectorRegOfWidth<ElementWidth, Class>() && - ShiftExtendTy == getShiftExtendType() && - getShiftExtendAmount() == Log2_32(ShiftWidth / 8); + DiagnosticPredicate isSVEVectorRegWithShiftExtend() const { + if (Kind != k_Register || Reg.Kind != RegKind::SVEDataVector) + return DiagnosticPredicateTy::NoMatch; + + if (isSVEVectorRegOfWidth<ElementWidth, Class>() && + ShiftExtendTy == getShiftExtendType() && + getShiftExtendAmount() == Log2_32(ShiftWidth / 8)) + return DiagnosticPredicateTy::Match; + + return DiagnosticPredicateTy::NearMatch; } bool isGPR32as64() const { @@ -899,12 +910,14 @@ public: } template <unsigned RegClassID, int ExtWidth> - bool isGPR64WithShiftExtend() const { - if (!isGPR64<RegClassID>()) - return false; - - return getShiftExtendType() == AArch64_AM::LSL && - getShiftExtendAmount() == Log2_32(ExtWidth / 8); + DiagnosticPredicate isGPR64WithShiftExtend() const { + if (Kind != k_Register || Reg.Kind != RegKind::Scalar) + return DiagnosticPredicateTy::NoMatch; + + if (isGPR64<RegClassID>() && getShiftExtendType() == AArch64_AM::LSL && + getShiftExtendAmount() == Log2_32(ExtWidth / 8)) + return DiagnosticPredicateTy::Match; + return DiagnosticPredicateTy::NearMatch; } /// Is this a vector list with the type implicit (presumably attached to the |

