Skip to content

Commit f1615e3

Browse files
authored
[WebAssembly] Remove Kind argument from WebAssemblyOperand (NFC) (#107157)
The `Kind` argument does not need to passed separately.
1 parent ff0f201 commit f1615e3

File tree

1 file changed

+23
-33
lines changed

1 file changed

+23
-33
lines changed

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ struct WebAssemblyOperand : public MCParsedAsmOperand {
7777
struct BrLOp BrL;
7878
};
7979

80-
WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, TokOp T)
81-
: Kind(K), StartLoc(Start), EndLoc(End), Tok(T) {}
82-
WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, IntOp I)
83-
: Kind(K), StartLoc(Start), EndLoc(End), Int(I) {}
84-
WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, FltOp F)
85-
: Kind(K), StartLoc(Start), EndLoc(End), Flt(F) {}
86-
WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, SymOp S)
87-
: Kind(K), StartLoc(Start), EndLoc(End), Sym(S) {}
88-
WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End)
89-
: Kind(K), StartLoc(Start), EndLoc(End), BrL() {}
80+
WebAssemblyOperand(SMLoc Start, SMLoc End, TokOp T)
81+
: Kind(Token), StartLoc(Start), EndLoc(End), Tok(T) {}
82+
WebAssemblyOperand(SMLoc Start, SMLoc End, IntOp I)
83+
: Kind(Integer), StartLoc(Start), EndLoc(End), Int(I) {}
84+
WebAssemblyOperand(SMLoc Start, SMLoc End, FltOp F)
85+
: Kind(Float), StartLoc(Start), EndLoc(End), Flt(F) {}
86+
WebAssemblyOperand(SMLoc Start, SMLoc End, SymOp S)
87+
: Kind(Symbol), StartLoc(Start), EndLoc(End), Sym(S) {}
88+
WebAssemblyOperand(SMLoc Start, SMLoc End)
89+
: Kind(BrList), StartLoc(Start), EndLoc(End), BrL() {}
9090

9191
~WebAssemblyOperand() {
9292
if (isBrList())
@@ -388,8 +388,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
388388
if (IsNegative)
389389
Val = -Val;
390390
Operands.push_back(std::make_unique<WebAssemblyOperand>(
391-
WebAssemblyOperand::Integer, Int.getLoc(), Int.getEndLoc(),
392-
WebAssemblyOperand::IntOp{Val}));
391+
Int.getLoc(), Int.getEndLoc(), WebAssemblyOperand::IntOp{Val}));
393392
Parser.Lex();
394393
}
395394

@@ -401,8 +400,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
401400
if (IsNegative)
402401
Val = -Val;
403402
Operands.push_back(std::make_unique<WebAssemblyOperand>(
404-
WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(),
405-
WebAssemblyOperand::FltOp{Val}));
403+
Flt.getLoc(), Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
406404
Parser.Lex();
407405
return false;
408406
}
@@ -423,8 +421,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
423421
if (IsNegative)
424422
Val = -Val;
425423
Operands.push_back(std::make_unique<WebAssemblyOperand>(
426-
WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(),
427-
WebAssemblyOperand::FltOp{Val}));
424+
Flt.getLoc(), Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
428425
Parser.Lex();
429426
return false;
430427
}
@@ -459,8 +456,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
459456
// up later.
460457
auto Tok = Lexer.getTok();
461458
Operands.push_back(std::make_unique<WebAssemblyOperand>(
462-
WebAssemblyOperand::Integer, Tok.getLoc(), Tok.getEndLoc(),
463-
WebAssemblyOperand::IntOp{-1}));
459+
Tok.getLoc(), Tok.getEndLoc(), WebAssemblyOperand::IntOp{-1}));
464460
}
465461
}
466462
return false;
@@ -474,8 +470,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
474470
NestingStack.back().Sig = Sig;
475471
}
476472
Operands.push_back(std::make_unique<WebAssemblyOperand>(
477-
WebAssemblyOperand::Integer, NameLoc, NameLoc,
478-
WebAssemblyOperand::IntOp{static_cast<int64_t>(BT)}));
473+
NameLoc, NameLoc, WebAssemblyOperand::IntOp{static_cast<int64_t>(BT)}));
479474
}
480475

481476
bool parseLimits(wasm::WasmLimits *Limits) {
@@ -512,25 +507,22 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
512507
GetOrCreateFunctionTableSymbol(getContext(), Tok.getString(), is64);
513508
const auto *Val = MCSymbolRefExpr::create(Sym, getContext());
514509
*Op = std::make_unique<WebAssemblyOperand>(
515-
WebAssemblyOperand::Symbol, Tok.getLoc(), Tok.getEndLoc(),
516-
WebAssemblyOperand::SymOp{Val});
510+
Tok.getLoc(), Tok.getEndLoc(), WebAssemblyOperand::SymOp{Val});
517511
Parser.Lex();
518512
return expect(AsmToken::Comma, ",");
519513
} else {
520514
const auto *Val =
521515
MCSymbolRefExpr::create(DefaultFunctionTable, getContext());
522516
*Op = std::make_unique<WebAssemblyOperand>(
523-
WebAssemblyOperand::Symbol, SMLoc(), SMLoc(),
524-
WebAssemblyOperand::SymOp{Val});
517+
SMLoc(), SMLoc(), WebAssemblyOperand::SymOp{Val});
525518
return false;
526519
}
527520
} else {
528521
// For the MVP there is at most one table whose number is 0, but we can't
529522
// write a table symbol or issue relocations. Instead we just ensure the
530523
// table is live and write a zero.
531524
getStreamer().emitSymbolAttribute(DefaultFunctionTable, MCSA_NoDeadStrip);
532-
*Op = std::make_unique<WebAssemblyOperand>(WebAssemblyOperand::Integer,
533-
SMLoc(), SMLoc(),
525+
*Op = std::make_unique<WebAssemblyOperand>(SMLoc(), SMLoc(),
534526
WebAssemblyOperand::IntOp{0});
535527
return false;
536528
}
@@ -564,7 +556,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
564556

565557
// Now construct the name as first operand.
566558
Operands.push_back(std::make_unique<WebAssemblyOperand>(
567-
WebAssemblyOperand::Token, NameLoc, SMLoc::getFromPointer(Name.end()),
559+
NameLoc, SMLoc::getFromPointer(Name.end()),
568560
WebAssemblyOperand::TokOp{Name}));
569561

570562
// If this instruction is part of a control flow structure, ensure
@@ -645,8 +637,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
645637
const MCExpr *Expr = MCSymbolRefExpr::create(
646638
WasmSym, MCSymbolRefExpr::VK_WASM_TYPEINDEX, Ctx);
647639
Operands.push_back(std::make_unique<WebAssemblyOperand>(
648-
WebAssemblyOperand::Symbol, Loc.getLoc(), Loc.getEndLoc(),
649-
WebAssemblyOperand::SymOp{Expr}));
640+
Loc.getLoc(), Loc.getEndLoc(), WebAssemblyOperand::SymOp{Expr}));
650641
}
651642

652643
while (Lexer.isNot(AsmToken::EndOfStatement)) {
@@ -671,8 +662,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
671662
if (Parser.parseExpression(Val, End))
672663
return error("Cannot parse symbol: ", Lexer.getTok());
673664
Operands.push_back(std::make_unique<WebAssemblyOperand>(
674-
WebAssemblyOperand::Symbol, Start, End,
675-
WebAssemblyOperand::SymOp{Val}));
665+
Start, End, WebAssemblyOperand::SymOp{Val}));
676666
if (checkForP2AlignIfLoadStore(Operands, Name))
677667
return true;
678668
}
@@ -705,8 +695,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
705695
}
706696
case AsmToken::LCurly: {
707697
Parser.Lex();
708-
auto Op = std::make_unique<WebAssemblyOperand>(
709-
WebAssemblyOperand::BrList, Tok.getLoc(), Tok.getEndLoc());
698+
auto Op =
699+
std::make_unique<WebAssemblyOperand>(Tok.getLoc(), Tok.getEndLoc());
710700
if (!Lexer.is(AsmToken::RCurly))
711701
for (;;) {
712702
Op->BrL.List.push_back(Lexer.getTok().getIntVal());

0 commit comments

Comments
 (0)