@@ -204,20 +204,20 @@ struct WebAssemblyOperand : public MCParsedAsmOperand {
204
204
};
205
205
206
206
// Perhaps this should go somewhere common.
207
- static wasm::WasmLimits DefaultLimits () {
207
+ static wasm::WasmLimits defaultLimits () {
208
208
return {wasm::WASM_LIMITS_FLAG_NONE, 0 , 0 };
209
209
}
210
210
211
- static MCSymbolWasm *GetOrCreateFunctionTableSymbol (MCContext &Ctx,
211
+ static MCSymbolWasm *getOrCreateFunctionTableSymbol (MCContext &Ctx,
212
212
const StringRef &Name,
213
- bool is64 ) {
213
+ bool Is64 ) {
214
214
MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol (Name));
215
215
if (Sym) {
216
216
if (!Sym->isFunctionTable ())
217
217
Ctx.reportError (SMLoc (), " symbol is not a wasm funcref table" );
218
218
} else {
219
219
Sym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (Name));
220
- Sym->setFunctionTable (is64 );
220
+ Sym->setFunctionTable (Is64 );
221
221
// The default function table is synthesized by the linker.
222
222
Sym->setUndefined ();
223
223
}
@@ -265,7 +265,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
265
265
MCSymbolWasm *DefaultFunctionTable = nullptr ;
266
266
MCSymbol *LastFunctionLabel = nullptr ;
267
267
268
- bool is64 ;
268
+ bool Is64 ;
269
269
270
270
WebAssemblyAsmTypeCheck TC;
271
271
// Don't type check if -no-type-check was set.
@@ -275,8 +275,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
275
275
WebAssemblyAsmParser (const MCSubtargetInfo &STI, MCAsmParser &Parser,
276
276
const MCInstrInfo &MII, const MCTargetOptions &Options)
277
277
: MCTargetAsmParser(Options, STI, MII), Parser(Parser),
278
- Lexer (Parser.getLexer()), is64 (STI.getTargetTriple().isArch64Bit()),
279
- TC(Parser, MII, is64 ), SkipTypeCheck(Options.MCNoTypeCheck) {
278
+ Lexer (Parser.getLexer()), Is64 (STI.getTargetTriple().isArch64Bit()),
279
+ TC(Parser, MII, Is64 ), SkipTypeCheck(Options.MCNoTypeCheck) {
280
280
setAvailableFeatures (ComputeAvailableFeatures (STI.getFeatureBits ()));
281
281
// Don't type check if this is inline asm, since that is a naked sequence of
282
282
// instructions without a function/locals decl.
@@ -290,8 +290,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
290
290
void Initialize (MCAsmParser &Parser) override {
291
291
MCAsmParserExtension::Initialize (Parser);
292
292
293
- DefaultFunctionTable = GetOrCreateFunctionTableSymbol (
294
- getContext (), " __indirect_function_table" , is64 );
293
+ DefaultFunctionTable = getOrCreateFunctionTableSymbol (
294
+ getContext (), " __indirect_function_table" , Is64 );
295
295
if (!STI->checkFeatures (" +reference-types" ))
296
296
DefaultFunctionTable->setOmitFromLinkingSection ();
297
297
}
@@ -538,28 +538,26 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
538
538
auto &Tok = Lexer.getTok ();
539
539
if (Tok.is (AsmToken::Identifier)) {
540
540
auto *Sym =
541
- GetOrCreateFunctionTableSymbol (getContext (), Tok.getString (), is64 );
541
+ getOrCreateFunctionTableSymbol (getContext (), Tok.getString (), Is64 );
542
542
const auto *Val = MCSymbolRefExpr::create (Sym, getContext ());
543
543
*Op = std::make_unique<WebAssemblyOperand>(
544
544
Tok.getLoc (), Tok.getEndLoc (), WebAssemblyOperand::SymOp{Val});
545
545
Parser.Lex ();
546
546
return expect (AsmToken::Comma, " ," );
547
- } else {
548
- const auto *Val =
549
- MCSymbolRefExpr::create (DefaultFunctionTable, getContext ());
550
- *Op = std::make_unique<WebAssemblyOperand>(
551
- SMLoc (), SMLoc (), WebAssemblyOperand::SymOp{Val});
552
- return false ;
553
547
}
554
- } else {
555
- // For the MVP there is at most one table whose number is 0, but we can't
556
- // write a table symbol or issue relocations. Instead we just ensure the
557
- // table is live and write a zero.
558
- getStreamer ().emitSymbolAttribute (DefaultFunctionTable, MCSA_NoDeadStrip);
559
- *Op = std::make_unique<WebAssemblyOperand>(SMLoc (), SMLoc (),
560
- WebAssemblyOperand::IntOp{0 });
548
+ const auto *Val =
549
+ MCSymbolRefExpr::create (DefaultFunctionTable, getContext ());
550
+ *Op = std::make_unique<WebAssemblyOperand>(
551
+ SMLoc (), SMLoc (), WebAssemblyOperand::SymOp{Val});
561
552
return false ;
562
553
}
554
+ // For the MVP there is at most one table whose number is 0, but we can't
555
+ // write a table symbol or issue relocations. Instead we just ensure the
556
+ // table is live and write a zero.
557
+ getStreamer ().emitSymbolAttribute (DefaultFunctionTable, MCSA_NoDeadStrip);
558
+ *Op = std::make_unique<WebAssemblyOperand>(SMLoc (), SMLoc (),
559
+ WebAssemblyOperand::IntOp{0 });
560
+ return false ;
563
561
}
564
562
565
563
bool parseInstruction (ParseInstructionInfo & /* Info*/ , StringRef Name,
@@ -674,7 +672,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
674
672
// expects to be able to recreate the actual unique-ified type indices.
675
673
auto &Ctx = getContext ();
676
674
auto Loc = Parser.getTok ();
677
- auto Signature = Ctx.createWasmSignature ();
675
+ auto * Signature = Ctx.createWasmSignature ();
678
676
if (parseSignature (Signature))
679
677
return true ;
680
678
// Got signature as block type, don't need more
@@ -879,9 +877,9 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
879
877
return false ;
880
878
}
881
879
882
- bool CheckDataSection () {
880
+ bool checkDataSection () {
883
881
if (CurrentState != DataSection) {
884
- auto WS = cast<MCSectionWasm>(getStreamer ().getCurrentSectionOnly ());
882
+ auto * WS = cast<MCSectionWasm>(getStreamer ().getCurrentSectionOnly ());
885
883
if (WS && WS->isText ())
886
884
return error (" data directive must occur in a data segment: " ,
887
885
Lexer.getTok ());
@@ -929,7 +927,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
929
927
return error (" Unknown type in .globaltype modifier: " , TypeTok);
930
928
}
931
929
// Now set this symbol with the correct type.
932
- auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
930
+ auto * WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
933
931
WasmSym->setType (wasm::WASM_SYMBOL_TYPE_GLOBAL);
934
932
WasmSym->setGlobalType (wasm::WasmGlobalType{uint8_t (*Type), Mutable});
935
933
// And emit the directive again.
@@ -954,15 +952,15 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
954
952
if (!ElemType)
955
953
return error (" Unknown type in .tabletype directive: " , ElemTypeTok);
956
954
957
- wasm::WasmLimits Limits = DefaultLimits ();
955
+ wasm::WasmLimits Limits = defaultLimits ();
958
956
if (isNext (AsmToken::Comma) && parseLimits (&Limits))
959
957
return ParseStatus::Failure;
960
958
961
959
// Now that we have the name and table type, we can actually create the
962
960
// symbol
963
- auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
961
+ auto * WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
964
962
WasmSym->setType (wasm::WASM_SYMBOL_TYPE_TABLE);
965
- if (is64 ) {
963
+ if (Is64 ) {
966
964
Limits.Flags |= wasm::WASM_LIMITS_FLAG_IS_64;
967
965
}
968
966
wasm::WasmTableType Type = {*ElemType, Limits};
@@ -980,7 +978,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
980
978
auto SymName = expectIdent ();
981
979
if (SymName.empty ())
982
980
return ParseStatus::Failure;
983
- auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
981
+ auto * WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
984
982
if (WasmSym->isDefined ()) {
985
983
// We push 'Function' either when a label is parsed or a .functype
986
984
// directive is parsed. The reason it is not easy to do this uniformly
@@ -1001,7 +999,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1001
999
CurrentState = FunctionStart;
1002
1000
LastFunctionLabel = WasmSym;
1003
1001
}
1004
- auto Signature = Ctx.createWasmSignature ();
1002
+ auto * Signature = Ctx.createWasmSignature ();
1005
1003
if (parseSignature (Signature))
1006
1004
return ParseStatus::Failure;
1007
1005
TC.funcDecl (*Signature);
@@ -1021,7 +1019,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1021
1019
auto ExportName = expectIdent ();
1022
1020
if (ExportName.empty ())
1023
1021
return ParseStatus::Failure;
1024
- auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1022
+ auto * WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1025
1023
WasmSym->setExportName (Ctx.allocateString (ExportName));
1026
1024
TOut.emitExportName (WasmSym, ExportName);
1027
1025
return expect (AsmToken::EndOfStatement, " EOL" );
@@ -1036,7 +1034,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1036
1034
auto ImportModule = expectIdent ();
1037
1035
if (ImportModule.empty ())
1038
1036
return ParseStatus::Failure;
1039
- auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1037
+ auto * WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1040
1038
WasmSym->setImportModule (Ctx.allocateString (ImportModule));
1041
1039
TOut.emitImportModule (WasmSym, ImportModule);
1042
1040
return expect (AsmToken::EndOfStatement, " EOL" );
@@ -1051,7 +1049,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1051
1049
auto ImportName = expectIdent ();
1052
1050
if (ImportName.empty ())
1053
1051
return ParseStatus::Failure;
1054
- auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1052
+ auto * WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1055
1053
WasmSym->setImportName (Ctx.allocateString (ImportName));
1056
1054
TOut.emitImportName (WasmSym, ImportName);
1057
1055
return expect (AsmToken::EndOfStatement, " EOL" );
@@ -1061,8 +1059,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1061
1059
auto SymName = expectIdent ();
1062
1060
if (SymName.empty ())
1063
1061
return ParseStatus::Failure;
1064
- auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1065
- auto Signature = Ctx.createWasmSignature ();
1062
+ auto * WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol (SymName));
1063
+ auto * Signature = Ctx.createWasmSignature ();
1066
1064
if (parseRegTypeList (Signature->Params ))
1067
1065
return ParseStatus::Failure;
1068
1066
WasmSym->setSignature (Signature);
@@ -1089,7 +1087,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1089
1087
DirectiveID.getString () == " .int16" ||
1090
1088
DirectiveID.getString () == " .int32" ||
1091
1089
DirectiveID.getString () == " .int64" ) {
1092
- if (CheckDataSection ())
1090
+ if (checkDataSection ())
1093
1091
return ParseStatus::Failure;
1094
1092
const MCExpr *Val;
1095
1093
SMLoc End;
@@ -1102,7 +1100,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1102
1100
}
1103
1101
1104
1102
if (DirectiveID.getString () == " .asciz" ) {
1105
- if (CheckDataSection ())
1103
+ if (checkDataSection ())
1106
1104
return ParseStatus::Failure;
1107
1105
std::string S;
1108
1106
if (Parser.parseEscapedString (S))
@@ -1146,7 +1144,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1146
1144
if (Op0.getImm () == -1 )
1147
1145
Op0.setImm (Align);
1148
1146
}
1149
- if (is64 ) {
1147
+ if (Is64 ) {
1150
1148
// Upgrade 32-bit loads/stores to 64-bit. These mostly differ by having
1151
1149
// an offset64 arg instead of offset32, but to the assembler matcher
1152
1150
// they're both immediates so don't get selected for.
@@ -1171,9 +1169,9 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1171
1169
SmallString<128 > Message;
1172
1170
raw_svector_ostream OS (Message);
1173
1171
OS << " instruction requires:" ;
1174
- for (unsigned i = 0 , e = MissingFeatures.size (); i != e ; ++i )
1175
- if (MissingFeatures.test (i ))
1176
- OS << ' ' << getSubtargetFeatureName (i );
1172
+ for (unsigned I = 0 , E = MissingFeatures.size (); I != E ; ++I )
1173
+ if (MissingFeatures.test (I ))
1174
+ OS << ' ' << getSubtargetFeatureName (I );
1177
1175
return Parser.Error (IDLoc, Message);
1178
1176
}
1179
1177
case Match_MnemonicFail:
@@ -1198,11 +1196,11 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1198
1196
1199
1197
void doBeforeLabelEmit (MCSymbol *Symbol, SMLoc IDLoc) override {
1200
1198
// Code below only applies to labels in text sections.
1201
- auto CWS = cast<MCSectionWasm>(getStreamer ().getCurrentSectionOnly ());
1199
+ auto * CWS = cast<MCSectionWasm>(getStreamer ().getCurrentSectionOnly ());
1202
1200
if (!CWS->isText ())
1203
1201
return ;
1204
1202
1205
- auto WasmSym = cast<MCSymbolWasm>(Symbol);
1203
+ auto * WasmSym = cast<MCSymbolWasm>(Symbol);
1206
1204
// Unlike other targets, we don't allow data in text sections (labels
1207
1205
// declared with .type @object).
1208
1206
if (WasmSym->getType () == wasm::WASM_SYMBOL_TYPE_DATA) {
@@ -1222,7 +1220,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1222
1220
// its name when we create this one. It would be nice to honor their
1223
1221
// choice, while still ensuring that we create one if they forget.
1224
1222
// (that requires coordination with WasmAsmParser::parseSectionDirective)
1225
- auto SecName = " .text." + SymName;
1223
+ std::string SecName = ( " .text." + SymName). str () ;
1226
1224
1227
1225
auto *Group = CWS->getGroup ();
1228
1226
// If the current section is a COMDAT, also set the flag on the symbol.
@@ -1259,7 +1257,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
1259
1257
if (!SkipTypeCheck)
1260
1258
TC.endOfFunction (ErrorLoc);
1261
1259
// Reset the type checker state.
1262
- TC.Clear ();
1260
+ TC.clear ();
1263
1261
}
1264
1262
1265
1263
void onEndOfFile () override { ensureEmptyNestingStack (); }
@@ -1277,7 +1275,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmParser() {
1277
1275
#define GET_MATCHER_IMPLEMENTATION
1278
1276
#include " WebAssemblyGenAsmMatcher.inc"
1279
1277
1280
- StringRef GetMnemonic (unsigned Opc) {
1278
+ StringRef getMnemonic (unsigned Opc) {
1281
1279
// FIXME: linear search!
1282
1280
for (auto &ME : MatchTable0) {
1283
1281
if (ME.Opcode == Opc) {
0 commit comments