@@ -420,9 +420,21 @@ struct Reg : public Field<tokenIndex, BitRangeSet<BitRange>> {
420
420
if (!success) {
421
421
return Error (line, " Unknown register '" + regToken + " '" );
422
422
}
423
+
424
+ // Allow implementations to hook into verification.
425
+ if (auto res = RegImpl::verifyApply (line, regIndex); res.isError ()) {
426
+ return res;
427
+ }
428
+
423
429
instruction |= BitRange ().apply (regIndex);
424
430
return Result<>::def ();
425
431
}
432
+
433
+ // Implementation-specific hook for verification of apply-time register index.
434
+ static Result<> verifyApply (const TokenizedSrcLine &, unsigned ) {
435
+ return Result<>::def ();
436
+ }
437
+
426
438
// / Decodes this register into its name. Adds it to the assembly line.
427
439
static bool decode (const Instr_T instruction, const Reg_T,
428
440
const ReverseSymbolMap &, LineTokens &line) {
@@ -484,7 +496,8 @@ struct ImmPartSet {
484
496
constexpr static void apply (const Instr_T value, Instr_T &instruction) {
485
497
(ImmParts::apply (value, instruction), ...);
486
498
}
487
- // / Decodes this immediate into its value by combining values from each part.
499
+ // / Decodes this immediate into its value by combining values from each
500
+ // / part.
488
501
constexpr static void decode (Instr_T &value, const Instr_T instruction) {
489
502
(ImmParts::decode (value, instruction), ...);
490
503
}
@@ -553,8 +566,8 @@ struct ImmBase : public Field<tokenIndex, typename ImmParts::BitRanges> {
553
566
using Reg_T_S = typename std::make_signed<Reg_T>::type;
554
567
using Reg_T_U = typename std::make_unsigned<Reg_T>::type;
555
568
556
- // / Converts a string to its immediate value (if it exists). Success is set to
557
- // / false if this fails.
569
+ // / Converts a string to its immediate value (if it exists). Success is set
570
+ // / to false if this fails.
558
571
constexpr static int64_t getImm (const QString &immToken, bool &success,
559
572
ImmConvInfo &convInfo) {
560
573
return repr == Repr::Signed
@@ -690,8 +703,8 @@ template <unsigned tokenIndex, unsigned width, Repr repr, typename ImmParts,
690
703
using ImmSym =
691
704
ImmBase<tokenIndex, width, repr, ImmParts, symbolType, defaultTransformer>;
692
705
693
- /* * @brief Shorthand for an Immediate with the default value transformer and no
694
- * symbol type. */
706
+ /* * @brief Shorthand for an Immediate with the default value transformer and
707
+ * no symbol type. */
695
708
template <unsigned tokenIndex, unsigned width, Repr repr, typename ImmParts>
696
709
using Imm = ImmBase<tokenIndex, width, repr, ImmParts, SymbolType::None,
697
710
defaultTransformer>;
0 commit comments