[loong64][mips][regexp] Add dedicated enums for standard character sets
Port commit b4aa41d0fc
Change-Id: I00e7b81450a1a751b536d29bc4bb4b69ad57b7c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3218720
Auto-Submit: Liu yu <liuyu@loongson.cn>
Reviewed-by: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#77351}
This commit is contained in:
parent
7fdf5e141e
commit
728e209030
@ -476,11 +476,12 @@ void RegExpMacroAssemblerLOONG64::CheckBitInTable(Handle<ByteArray> table,
|
||||
}
|
||||
|
||||
bool RegExpMacroAssemblerLOONG64::CheckSpecialCharacterClass(
|
||||
base::uc16 type, Label* on_no_match) {
|
||||
StandardCharacterSet type, Label* on_no_match) {
|
||||
// Range checks (c in min..max) are generally implemented by an unsigned
|
||||
// (c - min) <= (max - min) check.
|
||||
// TODO(jgruber): No custom implementation (yet): s(UC16), S(UC16).
|
||||
switch (type) {
|
||||
case 's':
|
||||
case StandardCharacterSet::kWhitespace:
|
||||
// Match space-characters.
|
||||
if (mode_ == LATIN1) {
|
||||
// One byte space characters are '\t'..'\r', ' ' and \u00a0.
|
||||
@ -495,20 +496,20 @@ bool RegExpMacroAssemblerLOONG64::CheckSpecialCharacterClass(
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case 'S':
|
||||
case StandardCharacterSet::kNotWhitespace:
|
||||
// The emitted code for generic character classes is good enough.
|
||||
return false;
|
||||
case 'd':
|
||||
case StandardCharacterSet::kDigit:
|
||||
// Match Latin1 digits ('0'..'9').
|
||||
__ Sub_d(a0, current_character(), Operand('0'));
|
||||
BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0'));
|
||||
return true;
|
||||
case 'D':
|
||||
case StandardCharacterSet::kNotDigit:
|
||||
// Match non Latin1-digits.
|
||||
__ Sub_d(a0, current_character(), Operand('0'));
|
||||
BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0'));
|
||||
return true;
|
||||
case '.': {
|
||||
case StandardCharacterSet::kNotLineTerminator: {
|
||||
// Match non-newlines (not 0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029).
|
||||
__ Xor(a0, current_character(), Operand(0x01));
|
||||
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C.
|
||||
@ -523,7 +524,7 @@ bool RegExpMacroAssemblerLOONG64::CheckSpecialCharacterClass(
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'n': {
|
||||
case StandardCharacterSet::kLineTerminator: {
|
||||
// Match newlines (0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029).
|
||||
__ Xor(a0, current_character(), Operand(0x01));
|
||||
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C.
|
||||
@ -542,7 +543,7 @@ bool RegExpMacroAssemblerLOONG64::CheckSpecialCharacterClass(
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'w': {
|
||||
case StandardCharacterSet::kWord: {
|
||||
if (mode_ != LATIN1) {
|
||||
// Table is 256 entries, so all Latin1 characters can be tested.
|
||||
BranchOrBacktrack(on_no_match, hi, current_character(), Operand('z'));
|
||||
@ -554,7 +555,7 @@ bool RegExpMacroAssemblerLOONG64::CheckSpecialCharacterClass(
|
||||
BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg));
|
||||
return true;
|
||||
}
|
||||
case 'W': {
|
||||
case StandardCharacterSet::kNotWord: {
|
||||
Label done;
|
||||
if (mode_ != LATIN1) {
|
||||
// Table is 256 entries, so all Latin1 characters can be tested.
|
||||
@ -570,12 +571,9 @@ bool RegExpMacroAssemblerLOONG64::CheckSpecialCharacterClass(
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case '*':
|
||||
case StandardCharacterSet::kEverything:
|
||||
// Match any character.
|
||||
return true;
|
||||
// No custom implementation (yet): s(UC16), S(UC16).
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerLOONG64
|
||||
// Checks whether the given offset from the current position is before
|
||||
// the end of the string.
|
||||
virtual void CheckPosition(int cp_offset, Label* on_outside_input);
|
||||
virtual bool CheckSpecialCharacterClass(base::uc16 type, Label* on_no_match);
|
||||
virtual bool CheckSpecialCharacterClass(StandardCharacterSet type,
|
||||
Label* on_no_match);
|
||||
virtual void Fail();
|
||||
virtual Handle<HeapObject> GetCode(Handle<String> source);
|
||||
virtual void GoTo(Label* label);
|
||||
|
@ -491,12 +491,13 @@ void RegExpMacroAssemblerMIPS::CheckBitInTable(
|
||||
BranchOrBacktrack(on_bit_set, ne, a0, Operand(zero_reg));
|
||||
}
|
||||
|
||||
bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
Label* on_no_match) {
|
||||
bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(
|
||||
StandardCharacterSet type, Label* on_no_match) {
|
||||
// Range checks (c in min..max) are generally implemented by an unsigned
|
||||
// (c - min) <= (max - min) check.
|
||||
// TODO(jgruber): No custom implementation (yet): s(UC16), S(UC16).
|
||||
switch (type) {
|
||||
case 's':
|
||||
case StandardCharacterSet::kWhitespace:
|
||||
// Match space-characters.
|
||||
if (mode_ == LATIN1) {
|
||||
// One byte space characters are '\t'..'\r', ' ' and \u00a0.
|
||||
@ -511,20 +512,20 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case 'S':
|
||||
case StandardCharacterSet::kNotWhitespace:
|
||||
// The emitted code for generic character classes is good enough.
|
||||
return false;
|
||||
case 'd':
|
||||
case StandardCharacterSet::kDigit:
|
||||
// Match Latin1 digits ('0'..'9').
|
||||
__ Subu(a0, current_character(), Operand('0'));
|
||||
BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0'));
|
||||
return true;
|
||||
case 'D':
|
||||
case StandardCharacterSet::kNotDigit:
|
||||
// Match non Latin1-digits.
|
||||
__ Subu(a0, current_character(), Operand('0'));
|
||||
BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0'));
|
||||
return true;
|
||||
case '.': {
|
||||
case StandardCharacterSet::kNotLineTerminator: {
|
||||
// Match non-newlines (not 0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029).
|
||||
__ Xor(a0, current_character(), Operand(0x01));
|
||||
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C.
|
||||
@ -539,7 +540,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'n': {
|
||||
case StandardCharacterSet::kLineTerminator: {
|
||||
// Match newlines (0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029).
|
||||
__ Xor(a0, current_character(), Operand(0x01));
|
||||
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C.
|
||||
@ -558,7 +559,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'w': {
|
||||
case StandardCharacterSet::kWord: {
|
||||
if (mode_ != LATIN1) {
|
||||
// Table is 256 entries, so all Latin1 characters can be tested.
|
||||
BranchOrBacktrack(on_no_match, hi, current_character(), Operand('z'));
|
||||
@ -570,7 +571,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg));
|
||||
return true;
|
||||
}
|
||||
case 'W': {
|
||||
case StandardCharacterSet::kNotWord: {
|
||||
Label done;
|
||||
if (mode_ != LATIN1) {
|
||||
// Table is 256 entries, so all Latin1 characters can be tested.
|
||||
@ -586,12 +587,9 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case '*':
|
||||
case StandardCharacterSet::kEverything:
|
||||
// Match any character.
|
||||
return true;
|
||||
// No custom implementation (yet): s(UC16), S(UC16).
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerMIPS
|
||||
// Checks whether the given offset from the current position is before
|
||||
// the end of the string.
|
||||
virtual void CheckPosition(int cp_offset, Label* on_outside_input);
|
||||
virtual bool CheckSpecialCharacterClass(base::uc16 type, Label* on_no_match);
|
||||
virtual bool CheckSpecialCharacterClass(StandardCharacterSet type,
|
||||
Label* on_no_match);
|
||||
virtual void Fail();
|
||||
virtual Handle<HeapObject> GetCode(Handle<String> source);
|
||||
virtual void GoTo(Label* label);
|
||||
|
@ -523,12 +523,13 @@ void RegExpMacroAssemblerMIPS::CheckBitInTable(
|
||||
BranchOrBacktrack(on_bit_set, ne, a0, Operand(zero_reg));
|
||||
}
|
||||
|
||||
bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
Label* on_no_match) {
|
||||
bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(
|
||||
StandardCharacterSet type, Label* on_no_match) {
|
||||
// Range checks (c in min..max) are generally implemented by an unsigned
|
||||
// (c - min) <= (max - min) check.
|
||||
// TODO(jgruber): No custom implementation (yet): s(UC16), S(UC16).
|
||||
switch (type) {
|
||||
case 's':
|
||||
case StandardCharacterSet::kWhitespace:
|
||||
// Match space-characters.
|
||||
if (mode_ == LATIN1) {
|
||||
// One byte space characters are '\t'..'\r', ' ' and \u00a0.
|
||||
@ -543,20 +544,20 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case 'S':
|
||||
case StandardCharacterSet::kNotWhitespace:
|
||||
// The emitted code for generic character classes is good enough.
|
||||
return false;
|
||||
case 'd':
|
||||
case StandardCharacterSet::kDigit:
|
||||
// Match Latin1 digits ('0'..'9').
|
||||
__ Dsubu(a0, current_character(), Operand('0'));
|
||||
BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0'));
|
||||
return true;
|
||||
case 'D':
|
||||
case StandardCharacterSet::kNotDigit:
|
||||
// Match non Latin1-digits.
|
||||
__ Dsubu(a0, current_character(), Operand('0'));
|
||||
BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0'));
|
||||
return true;
|
||||
case '.': {
|
||||
case StandardCharacterSet::kNotLineTerminator: {
|
||||
// Match non-newlines (not 0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029).
|
||||
__ Xor(a0, current_character(), Operand(0x01));
|
||||
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C.
|
||||
@ -571,7 +572,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'n': {
|
||||
case StandardCharacterSet::kLineTerminator: {
|
||||
// Match newlines (0x0A('\n'), 0x0D('\r'), 0x2028 and 0x2029).
|
||||
__ Xor(a0, current_character(), Operand(0x01));
|
||||
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0B or 0x0C.
|
||||
@ -590,7 +591,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case 'w': {
|
||||
case StandardCharacterSet::kWord: {
|
||||
if (mode_ != LATIN1) {
|
||||
// Table is 256 entries, so all Latin1 characters can be tested.
|
||||
BranchOrBacktrack(on_no_match, hi, current_character(), Operand('z'));
|
||||
@ -602,7 +603,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
BranchOrBacktrack(on_no_match, eq, a0, Operand(zero_reg));
|
||||
return true;
|
||||
}
|
||||
case 'W': {
|
||||
case StandardCharacterSet::kNotWord: {
|
||||
Label done;
|
||||
if (mode_ != LATIN1) {
|
||||
// Table is 256 entries, so all Latin1 characters can be tested.
|
||||
@ -618,12 +619,9 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(base::uc16 type,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case '*':
|
||||
case StandardCharacterSet::kEverything:
|
||||
// Match any character.
|
||||
return true;
|
||||
// No custom implementation (yet): s(UC16), S(UC16).
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,8 @@ class V8_EXPORT_PRIVATE RegExpMacroAssemblerMIPS
|
||||
// Checks whether the given offset from the current position is before
|
||||
// the end of the string.
|
||||
virtual void CheckPosition(int cp_offset, Label* on_outside_input);
|
||||
virtual bool CheckSpecialCharacterClass(base::uc16 type, Label* on_no_match);
|
||||
virtual bool CheckSpecialCharacterClass(StandardCharacterSet type,
|
||||
Label* on_no_match);
|
||||
virtual void Fail();
|
||||
virtual Handle<HeapObject> GetCode(Handle<String> source);
|
||||
virtual void GoTo(Label* label);
|
||||
|
Loading…
Reference in New Issue
Block a user