bool generateImmOutOfRangeError(OperandVector &Operands, uint64_t ErrorInfo,
int64_t Lower, int64_t Upper,
const Twine &Msg);
+ bool generateImmOutOfRangeError(SMLoc ErrorLoc, int64_t Lower, int64_t Upper,
+ const Twine &Msg);
bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
OperandVector &Operands, MCStreamer &Out,
}
bool RISCVAsmParser::generateImmOutOfRangeError(
+ SMLoc ErrorLoc, int64_t Lower, int64_t Upper,
+ const Twine &Msg = "immediate must be an integer in the range") {
+ return Error(ErrorLoc, Msg + " [" + Twine(Lower) + ", " + Twine(Upper) + "]");
+}
+
+bool RISCVAsmParser::generateImmOutOfRangeError(
OperandVector &Operands, uint64_t ErrorInfo, int64_t Lower, int64_t Upper,
const Twine &Msg = "immediate must be an integer in the range") {
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();
- return Error(ErrorLoc, Msg + " [" + Twine(Lower) + ", " + Twine(Upper) + "]");
+ return generateImmOutOfRangeError(ErrorLoc, Lower, Upper, Msg);
}
bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
break;
}
- Error(S, "opcode must be a valid opcode name or an immediate in the range "
- "[0, 127]");
+ generateImmOutOfRangeError(S, 0, 127,
+ "opcode must be a valid opcode name or an "
+ "immediate in the range");
return MatchOperand_ParseFail;
}
}
}
- Error(S, "opcode must be a valid opcode name or an immediate in the range "
- "[0, 2]");
+ generateImmOutOfRangeError(S, 0, 2,
+ "opcode must be a valid opcode name or an "
+ "immediate in the range");
return MatchOperand_ParseFail;
}
}
}
- Twine Msg = "immediate must be an integer in the range";
- Error(S, Msg + " [" + Twine(0) + ", " + Twine((1 << 12) - 1) + "]");
+ generateImmOutOfRangeError(S, 0, (1 << 12) - 1);
return MatchOperand_ParseFail;
}
case AsmToken::Identifier: {
return MatchOperand_Success;
}
- Twine Msg = "operand must be a valid system register name "
- "or an integer in the range";
- Error(S, Msg + " [" + Twine(0) + ", " + Twine((1 << 12) - 1) + "]");
+ generateImmOutOfRangeError(S, 0, (1 << 12) - 1,
+ "operand must be a valid system register name "
+ "or an integer in the range");
return MatchOperand_ParseFail;
}
case AsmToken::Percent: {
// Discard operand with modifier.
- Twine Msg = "immediate must be an integer in the range";
- Error(S, Msg + " [" + Twine(0) + ", " + Twine((1 << 12) - 1) + "]");
+ generateImmOutOfRangeError(S, 0, (1 << 12) - 1);
return MatchOperand_ParseFail;
}
}