@@ -73,9 +73,7 @@ class VEAsmParser : public MCTargetAsmParser {
7373 ParseStatus parseVEAsmOperand (std::unique_ptr<VEOperand> &Operand);
7474
7575 // Helper function to parse expression with a symbol.
76- const MCExpr *extractModifierFromExpr (const MCExpr *E,
77- VEMCExpr::VariantKind &Variant);
78- const MCExpr *fixupVariantKind (const MCExpr *E);
76+ const MCExpr *extractSpecifier (const MCExpr *E, VEMCExpr::Specifier &Variant);
7977 bool parseExpression (const MCExpr *&EVal);
8078
8179 // Split the mnemonic stripping conditional code and quantifiers
@@ -1035,15 +1033,14 @@ bool VEAsmParser::parseLiteralValues(unsigned Size, SMLoc L) {
10351033 return (parseMany (parseOne));
10361034}
10371035
1038- // / Extract \code @lo32/@hi32/etc \endcode modifier from expression.
1036+ // / Extract \code @lo32/@hi32/etc \endcode specifier from expression.
10391037// / Recursively scan the expression and check for VK_HI32/LO32/etc
10401038// / symbol variants. If all symbols with modifier use the same
1041- // / variant, return the corresponding VEMCExpr::VariantKind ,
1039+ // / variant, return the corresponding VEMCExpr::Specifier ,
10421040// / and a modified expression using the default symbol variant.
10431041// / Otherwise, return NULL.
1044- const MCExpr *
1045- VEAsmParser::extractModifierFromExpr (const MCExpr *E,
1046- VEMCExpr::VariantKind &Variant) {
1042+ const MCExpr *VEAsmParser::extractSpecifier (const MCExpr *E,
1043+ VEMCExpr::Specifier &Variant) {
10471044 MCContext &Context = getParser ().getContext ();
10481045 Variant = VEMCExpr::VK_None;
10491046
@@ -1055,7 +1052,7 @@ VEAsmParser::extractModifierFromExpr(const MCExpr *E,
10551052 case MCExpr::SymbolRef: {
10561053 const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(E);
10571054
1058- switch (getVariantKind (SRE)) {
1055+ switch (getSpecifier (SRE)) {
10591056 case VEMCExpr::VK_None:
10601057 // Use VK_REFLONG to a symbol without modifiers.
10611058 Variant = VEMCExpr::VK_REFLONG;
@@ -1111,17 +1108,17 @@ VEAsmParser::extractModifierFromExpr(const MCExpr *E,
11111108
11121109 case MCExpr::Unary: {
11131110 const MCUnaryExpr *UE = cast<MCUnaryExpr>(E);
1114- const MCExpr *Sub = extractModifierFromExpr (UE->getSubExpr (), Variant);
1111+ const MCExpr *Sub = extractSpecifier (UE->getSubExpr (), Variant);
11151112 if (!Sub)
11161113 return nullptr ;
11171114 return MCUnaryExpr::create (UE->getOpcode (), Sub, Context);
11181115 }
11191116
11201117 case MCExpr::Binary: {
11211118 const MCBinaryExpr *BE = cast<MCBinaryExpr>(E);
1122- VEMCExpr::VariantKind LHSVariant, RHSVariant;
1123- const MCExpr *LHS = extractModifierFromExpr (BE->getLHS (), LHSVariant);
1124- const MCExpr *RHS = extractModifierFromExpr (BE->getRHS (), RHSVariant);
1119+ VEMCExpr::Specifier LHSVariant, RHSVariant;
1120+ const MCExpr *LHS = extractSpecifier (BE->getLHS (), LHSVariant);
1121+ const MCExpr *RHS = extractSpecifier (BE->getRHS (), RHSVariant);
11251122
11261123 if (!LHS && !RHS)
11271124 return nullptr ;
@@ -1147,49 +1144,18 @@ VEAsmParser::extractModifierFromExpr(const MCExpr *E,
11471144 llvm_unreachable (" Invalid expression kind!" );
11481145}
11491146
1150- const MCExpr *VEAsmParser::fixupVariantKind (const MCExpr *E) {
1151- MCContext &Context = getParser ().getContext ();
1152-
1153- switch (E->getKind ()) {
1154- case MCExpr::Target:
1155- case MCExpr::Constant:
1156- case MCExpr::SymbolRef:
1157- return E;
1158-
1159- case MCExpr::Unary: {
1160- const MCUnaryExpr *UE = cast<MCUnaryExpr>(E);
1161- const MCExpr *Sub = fixupVariantKind (UE->getSubExpr ());
1162- if (Sub == UE->getSubExpr ())
1163- return E;
1164- return MCUnaryExpr::create (UE->getOpcode (), Sub, Context);
1165- }
1166-
1167- case MCExpr::Binary: {
1168- const MCBinaryExpr *BE = cast<MCBinaryExpr>(E);
1169- const MCExpr *LHS = fixupVariantKind (BE->getLHS ());
1170- const MCExpr *RHS = fixupVariantKind (BE->getRHS ());
1171- if (LHS == BE->getLHS () && RHS == BE->getRHS ())
1172- return E;
1173- return MCBinaryExpr::create (BE->getOpcode (), LHS, RHS, Context);
1174- }
1175- }
1176-
1177- llvm_unreachable (" Invalid expression kind!" );
1178- }
1179-
1180- // / ParseExpression. This differs from the default "parseExpression" in that
1181- // / it handles modifiers.
1147+ // / This differs from the default "parseExpression" in that it handles
1148+ // / relocation specifiers.
11821149bool VEAsmParser::parseExpression (const MCExpr *&EVal) {
11831150 // Handle \code symbol @lo32/@hi32/etc \endcode.
11841151 if (getParser ().parseExpression (EVal))
11851152 return true ;
11861153
11871154 // Convert MCSymbolRefExpr with VK_* to MCExpr with VK_*.
1188- EVal = fixupVariantKind (EVal);
1189- VEMCExpr::VariantKind Variant;
1190- const MCExpr *E = extractModifierFromExpr (EVal, Variant);
1155+ VEMCExpr::Specifier Specifier;
1156+ const MCExpr *E = extractSpecifier (EVal, Specifier);
11911157 if (E)
1192- EVal = VEMCExpr::create (Variant , E, getParser ().getContext ());
1158+ EVal = VEMCExpr::create (Specifier , E, getParser ().getContext ());
11931159
11941160 return false ;
11951161}
0 commit comments