[llvm] [WebAssembly] Remove Kind argument from WebAssemblyOperand (NFC) (PR #107157)
Heejin Ahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 15:06:33 PDT 2024
https://github.com/aheejin created https://github.com/llvm/llvm-project/pull/107157
The `Kind` argument does not need to passed separately.
>From 103502466d09122729f5b85cd00a48c9d6853604 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Sun, 18 Aug 2024 06:39:37 +0000
Subject: [PATCH] [WebAssembly] Remove Kind argument from WebAssemblyOperand
(NFC)
The `Kind` argument does not need to passed separately.
---
.../AsmParser/WebAssemblyAsmParser.cpp | 56 ++++++++-----------
1 file changed, 23 insertions(+), 33 deletions(-)
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
index c63740d267819c..24a9ad67cfe042 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -77,16 +77,16 @@ struct WebAssemblyOperand : public MCParsedAsmOperand {
struct BrLOp BrL;
};
- WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, TokOp T)
- : Kind(K), StartLoc(Start), EndLoc(End), Tok(T) {}
- WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, IntOp I)
- : Kind(K), StartLoc(Start), EndLoc(End), Int(I) {}
- WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, FltOp F)
- : Kind(K), StartLoc(Start), EndLoc(End), Flt(F) {}
- WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End, SymOp S)
- : Kind(K), StartLoc(Start), EndLoc(End), Sym(S) {}
- WebAssemblyOperand(KindTy K, SMLoc Start, SMLoc End)
- : Kind(K), StartLoc(Start), EndLoc(End), BrL() {}
+ WebAssemblyOperand(SMLoc Start, SMLoc End, TokOp T)
+ : Kind(Token), StartLoc(Start), EndLoc(End), Tok(T) {}
+ WebAssemblyOperand(SMLoc Start, SMLoc End, IntOp I)
+ : Kind(Integer), StartLoc(Start), EndLoc(End), Int(I) {}
+ WebAssemblyOperand(SMLoc Start, SMLoc End, FltOp F)
+ : Kind(Float), StartLoc(Start), EndLoc(End), Flt(F) {}
+ WebAssemblyOperand(SMLoc Start, SMLoc End, SymOp S)
+ : Kind(Symbol), StartLoc(Start), EndLoc(End), Sym(S) {}
+ WebAssemblyOperand(SMLoc Start, SMLoc End)
+ : Kind(BrList), StartLoc(Start), EndLoc(End), BrL() {}
~WebAssemblyOperand() {
if (isBrList())
@@ -388,8 +388,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
if (IsNegative)
Val = -Val;
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Integer, Int.getLoc(), Int.getEndLoc(),
- WebAssemblyOperand::IntOp{Val}));
+ Int.getLoc(), Int.getEndLoc(), WebAssemblyOperand::IntOp{Val}));
Parser.Lex();
}
@@ -401,8 +400,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
if (IsNegative)
Val = -Val;
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(),
- WebAssemblyOperand::FltOp{Val}));
+ Flt.getLoc(), Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
Parser.Lex();
return false;
}
@@ -423,8 +421,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
if (IsNegative)
Val = -Val;
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(),
- WebAssemblyOperand::FltOp{Val}));
+ Flt.getLoc(), Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
Parser.Lex();
return false;
}
@@ -459,8 +456,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
// up later.
auto Tok = Lexer.getTok();
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Integer, Tok.getLoc(), Tok.getEndLoc(),
- WebAssemblyOperand::IntOp{-1}));
+ Tok.getLoc(), Tok.getEndLoc(), WebAssemblyOperand::IntOp{-1}));
}
}
return false;
@@ -474,8 +470,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
NestingStack.back().Sig = Sig;
}
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Integer, NameLoc, NameLoc,
- WebAssemblyOperand::IntOp{static_cast<int64_t>(BT)}));
+ NameLoc, NameLoc, WebAssemblyOperand::IntOp{static_cast<int64_t>(BT)}));
}
bool parseLimits(wasm::WasmLimits *Limits) {
@@ -512,16 +507,14 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
GetOrCreateFunctionTableSymbol(getContext(), Tok.getString(), is64);
const auto *Val = MCSymbolRefExpr::create(Sym, getContext());
*Op = std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Symbol, Tok.getLoc(), Tok.getEndLoc(),
- WebAssemblyOperand::SymOp{Val});
+ Tok.getLoc(), Tok.getEndLoc(), WebAssemblyOperand::SymOp{Val});
Parser.Lex();
return expect(AsmToken::Comma, ",");
} else {
const auto *Val =
MCSymbolRefExpr::create(DefaultFunctionTable, getContext());
*Op = std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Symbol, SMLoc(), SMLoc(),
- WebAssemblyOperand::SymOp{Val});
+ SMLoc(), SMLoc(), WebAssemblyOperand::SymOp{Val});
return false;
}
} else {
@@ -529,8 +522,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
// write a table symbol or issue relocations. Instead we just ensure the
// table is live and write a zero.
getStreamer().emitSymbolAttribute(DefaultFunctionTable, MCSA_NoDeadStrip);
- *Op = std::make_unique<WebAssemblyOperand>(WebAssemblyOperand::Integer,
- SMLoc(), SMLoc(),
+ *Op = std::make_unique<WebAssemblyOperand>(SMLoc(), SMLoc(),
WebAssemblyOperand::IntOp{0});
return false;
}
@@ -564,7 +556,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
// Now construct the name as first operand.
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Token, NameLoc, SMLoc::getFromPointer(Name.end()),
+ NameLoc, SMLoc::getFromPointer(Name.end()),
WebAssemblyOperand::TokOp{Name}));
// If this instruction is part of a control flow structure, ensure
@@ -645,8 +637,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
const MCExpr *Expr = MCSymbolRefExpr::create(
WasmSym, MCSymbolRefExpr::VK_WASM_TYPEINDEX, Ctx);
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Symbol, Loc.getLoc(), Loc.getEndLoc(),
- WebAssemblyOperand::SymOp{Expr}));
+ Loc.getLoc(), Loc.getEndLoc(), WebAssemblyOperand::SymOp{Expr}));
}
while (Lexer.isNot(AsmToken::EndOfStatement)) {
@@ -671,8 +662,7 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
if (Parser.parseExpression(Val, End))
return error("Cannot parse symbol: ", Lexer.getTok());
Operands.push_back(std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::Symbol, Start, End,
- WebAssemblyOperand::SymOp{Val}));
+ Start, End, WebAssemblyOperand::SymOp{Val}));
if (checkForP2AlignIfLoadStore(Operands, Name))
return true;
}
@@ -705,8 +695,8 @@ class WebAssemblyAsmParser final : public MCTargetAsmParser {
}
case AsmToken::LCurly: {
Parser.Lex();
- auto Op = std::make_unique<WebAssemblyOperand>(
- WebAssemblyOperand::BrList, Tok.getLoc(), Tok.getEndLoc());
+ auto Op =
+ std::make_unique<WebAssemblyOperand>(Tok.getLoc(), Tok.getEndLoc());
if (!Lexer.is(AsmToken::RCurly))
for (;;) {
Op->BrL.List.push_back(Lexer.getTok().getIntVal());
More information about the llvm-commits
mailing list