diff options
Diffstat (limited to 'llvm/lib/Target/WebAssembly')
9 files changed, 47 insertions, 43 deletions
diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp index 6ae69a4..80df4ed 100644 --- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -212,12 +212,12 @@ static wasm::WasmLimits defaultLimits() { static MCSymbolWasm *getOrCreateFunctionTableSymbol(MCContext &Ctx, const StringRef &Name, bool Is64) { - MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol(Name)); + auto *Sym = static_cast<MCSymbolWasm *>(Ctx.lookupSymbol(Name)); if (Sym) { if (!Sym->isFunctionTable()) Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table"); } else { - Sym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(Name)); + Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name)); Sym->setFunctionTable(Is64); // The default function table is synthesized by the linker. Sym->setUndefined(); @@ -703,7 +703,7 @@ public: ExpectBlockType = false; // The "true" here will cause this to be a nameless symbol. MCSymbol *Sym = Ctx.createTempSymbol("typeindex", true); - auto *WasmSym = cast<MCSymbolWasm>(Sym); + auto *WasmSym = static_cast<MCSymbolWasm *>(Sym); WasmSym->setSignature(Signature); WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); const MCExpr *Expr = @@ -949,7 +949,8 @@ public: return error("Unknown type in .globaltype modifier: ", TypeTok); } // Now set this symbol with the correct type. - auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); + auto *WasmSym = + static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName)); WasmSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL); WasmSym->setGlobalType(wasm::WasmGlobalType{uint8_t(*Type), Mutable}); // And emit the directive again. @@ -980,7 +981,8 @@ public: // Now that we have the name and table type, we can actually create the // symbol - auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); + auto *WasmSym = + static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName)); WasmSym->setType(wasm::WASM_SYMBOL_TYPE_TABLE); if (Is64) { Limits.Flags |= wasm::WASM_LIMITS_FLAG_IS_64; @@ -1000,7 +1002,8 @@ public: auto SymName = expectIdent(); if (SymName.empty()) return ParseStatus::Failure; - auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); + auto *WasmSym = + static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName)); if (WasmSym->isDefined()) { // We push 'Function' either when a label is parsed or a .functype // directive is parsed. The reason it is not easy to do this uniformly @@ -1042,7 +1045,8 @@ public: auto ExportName = expectIdent(); if (ExportName.empty()) return ParseStatus::Failure; - auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); + auto *WasmSym = + static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName)); WasmSym->setExportName(Ctx.allocateString(ExportName)); TOut.emitExportName(WasmSym, ExportName); return expect(AsmToken::EndOfStatement, "EOL"); @@ -1057,7 +1061,8 @@ public: auto ImportModule = expectIdent(); if (ImportModule.empty()) return ParseStatus::Failure; - auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); + auto *WasmSym = + static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName)); WasmSym->setImportModule(Ctx.allocateString(ImportModule)); TOut.emitImportModule(WasmSym, ImportModule); return expect(AsmToken::EndOfStatement, "EOL"); @@ -1072,7 +1077,8 @@ public: auto ImportName = expectIdent(); if (ImportName.empty()) return ParseStatus::Failure; - auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); + auto *WasmSym = + static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName)); WasmSym->setImportName(Ctx.allocateString(ImportName)); TOut.emitImportName(WasmSym, ImportName); return expect(AsmToken::EndOfStatement, "EOL"); @@ -1082,7 +1088,8 @@ public: auto SymName = expectIdent(); if (SymName.empty()) return ParseStatus::Failure; - auto *WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); + auto *WasmSym = + static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(SymName)); auto *Signature = Ctx.createWasmSignature(); if (parseRegTypeList(Signature->Params)) return ParseStatus::Failure; @@ -1224,7 +1231,7 @@ public: if (!CWS->isText()) return; - auto *WasmSym = cast<MCSymbolWasm>(Symbol); + auto *WasmSym = static_cast<MCSymbolWasm *>(Symbol); // Unlike other targets, we don't allow data in text sections (labels // declared with .type @object). if (WasmSym->getType() == wasm::WASM_SYMBOL_TYPE_DATA) { diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp index 4a305ab..6943888 100644 --- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp +++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp @@ -258,7 +258,7 @@ bool WebAssemblyAsmTypeCheck::getGlobal(SMLoc ErrorLoc, const MCSymbolRefExpr *SymRef; if (getSymRef(ErrorLoc, GlobalOp, SymRef)) return true; - const auto *WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol()); + auto *WasmSym = static_cast<const MCSymbolWasm *>(&SymRef->getSymbol()); switch (WasmSym->getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA)) { case wasm::WASM_SYMBOL_TYPE_GLOBAL: Type = static_cast<wasm::ValType>(WasmSym->getGlobalType().Type); @@ -286,7 +286,7 @@ bool WebAssemblyAsmTypeCheck::getTable(SMLoc ErrorLoc, const MCOperand &TableOp, const MCSymbolRefExpr *SymRef; if (getSymRef(ErrorLoc, TableOp, SymRef)) return true; - const auto *WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol()); + auto *WasmSym = static_cast<const MCSymbolWasm *>(&SymRef->getSymbol()); if (WasmSym->getType().value_or(wasm::WASM_SYMBOL_TYPE_DATA) != wasm::WASM_SYMBOL_TYPE_TABLE) return typeError(ErrorLoc, StringRef("symbol ") + WasmSym->getName() + @@ -302,7 +302,7 @@ bool WebAssemblyAsmTypeCheck::getSignature(SMLoc ErrorLoc, const MCSymbolRefExpr *SymRef = nullptr; if (getSymRef(ErrorLoc, SigOp, SymRef)) return true; - const auto *WasmSym = cast<MCSymbolWasm>(&SymRef->getSymbol()); + auto *WasmSym = static_cast<const MCSymbolWasm *>(&SymRef->getSymbol()); Sig = WasmSym->getSignature(); if (!Sig || WasmSym->getType() != Type) { diff --git a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp index 0f7b27b..2a398d4 100644 --- a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -237,7 +237,7 @@ MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction( } else { // We don't have access to the signature, so create a symbol without one MCSymbol *Sym = getContext().createTempSymbol("typeindex", true); - auto *WasmSym = cast<MCSymbolWasm>(Sym); + auto *WasmSym = static_cast<MCSymbolWasm *>(Sym); WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); const MCExpr *Expr = MCSymbolRefExpr::create( WasmSym, WebAssembly::S_TYPEINDEX, getContext()); diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp index 2e97215..d8bfed9 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp @@ -380,7 +380,7 @@ void WebAssemblyInstPrinter::printWebAssemblySignatureOperand(const MCInst *MI, O << WebAssembly::anyTypeToString(Imm); } else { auto Expr = cast<MCSymbolRefExpr>(Op.getExpr()); - auto *Sym = cast<MCSymbolWasm>(&Expr->getSymbol()); + auto *Sym = static_cast<const MCSymbolWasm *>(&Expr->getSymbol()); if (Sym->getSignature()) { O << WebAssembly::signatureToString(Sym->getSignature()); } else { @@ -398,10 +398,10 @@ void WebAssemblyInstPrinter::printCatchList(const MCInst *MI, unsigned OpNo, auto PrintTagOp = [&](const MCOperand &Op) { const MCSymbolRefExpr *TagExpr = nullptr; - const MCSymbolWasm *TagSym = nullptr; + const MCSymbol *TagSym = nullptr; if (Op.isExpr()) { TagExpr = cast<MCSymbolRefExpr>(Op.getExpr()); - TagSym = cast<MCSymbolWasm>(&TagExpr->getSymbol()); + TagSym = &TagExpr->getSymbol(); O << TagSym->getName() << " "; } else { // When instructions are parsed from the disassembler, we have an diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp index cbaf10f..7096104 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp @@ -107,7 +107,7 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( encodeULEB128(uint32_t(MO.getImm()), OS); break; case WebAssembly::OPERAND_I64IMM: - encodeSLEB128(int64_t(MO.getImm()), OS); + encodeSLEB128(MO.getImm(), OS); break; case WebAssembly::OPERAND_SIGNATURE: case WebAssembly::OPERAND_VEC_I8IMM: diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp index 2cf4bec..ffbc7e1 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp @@ -66,7 +66,7 @@ static const MCSection *getTargetSection(const MCExpr *Expr) { unsigned WebAssemblyWasmObjectWriter::getRelocType( const MCValue &Target, const MCFixup &Fixup, const MCSectionWasm &FixupSection, bool IsLocRel) const { - auto &SymA = cast<MCSymbolWasm>(*Target.getAddSym()); + auto &SymA = static_cast<const MCSymbolWasm &>(*Target.getAddSym()); auto Spec = WebAssembly::Specifier(Target.getSpecifier()); switch (Spec) { case WebAssembly::S_GOT: diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp index 1bf070e..db832bc 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -171,10 +171,10 @@ MCSymbolWasm *WebAssemblyAsmPrinter::getMCSymbolForFunction( WebAssembly::signatureToString(Sig); report_fatal_error(Twine(Msg)); } - WasmSym = cast<MCSymbolWasm>( + WasmSym = static_cast<MCSymbolWasm *>( GetExternalSymbolSymbol(getEmscriptenInvokeSymbolName(Sig))); } else { - WasmSym = cast<MCSymbolWasm>(getSymbol(F)); + WasmSym = static_cast<MCSymbolWasm *>(getSymbol(F)); } return WasmSym; } @@ -186,9 +186,7 @@ void WebAssemblyAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) { } assert(!GV->isThreadLocal()); - - MCSymbolWasm *Sym = cast<MCSymbolWasm>(getSymbol(GV)); - + auto *Sym = static_cast<MCSymbolWasm *>(getSymbol(GV)); if (!Sym->getType()) { SmallVector<MVT, 1> VTs; Type *GlobalVT = GV->getValueType(); @@ -218,8 +216,7 @@ void WebAssemblyAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) { } MCSymbol *WebAssemblyAsmPrinter::getOrCreateWasmSymbol(StringRef Name) { - auto *WasmSym = cast<MCSymbolWasm>(GetExternalSymbolSymbol(Name)); - + auto *WasmSym = static_cast<MCSymbolWasm *>(GetExternalSymbolSymbol(Name)); // May be called multiple times, so early out. if (WasmSym->getType()) return WasmSym; @@ -312,7 +309,7 @@ void WebAssemblyAsmPrinter::emitDecls(const Module &M) { // not be found here. MachineModuleInfoWasm &MMIW = MMI->getObjFileInfo<MachineModuleInfoWasm>(); for (StringRef Name : MMIW.MachineSymbolsUsed) { - auto *WasmSym = cast<MCSymbolWasm>(getOrCreateWasmSymbol(Name)); + auto *WasmSym = static_cast<MCSymbolWasm *>(getOrCreateWasmSymbol(Name)); if (WasmSym->isFunction()) { // TODO(wvo): is there any case where this overlaps with the call to // emitFunctionType in the loop below? @@ -324,7 +321,7 @@ void WebAssemblyAsmPrinter::emitDecls(const Module &M) { // Emit .globaltype, .tagtype, or .tabletype declarations for extern // declarations, i.e. those that have only been declared (but not defined) // in the current module - auto Sym = cast_or_null<MCSymbolWasm>(It.getValue().Symbol); + auto Sym = static_cast<MCSymbolWasm *>(It.getValue().Symbol); if (Sym && !Sym->isDefined()) emitSymbolType(Sym); } @@ -381,7 +378,7 @@ void WebAssemblyAsmPrinter::emitDecls(const Module &M) { } if (F.hasFnAttribute("wasm-export-name")) { - auto *Sym = cast<MCSymbolWasm>(getSymbol(&F)); + auto *Sym = static_cast<MCSymbolWasm *>(getSymbol(&F)); StringRef Name = F.getFnAttribute("wasm-export-name").getValueAsString(); Sym->setExportName(OutContext.allocateString(Name)); getTargetStreamer()->emitExportName(Sym, Name); @@ -581,7 +578,7 @@ void WebAssemblyAsmPrinter::EmitFunctionAttributes(Module &M) { auto *GV = cast<GlobalVariable>(CS->getOperand(1)->stripPointerCasts()); StringRef AnnotationString; getConstantStringInfo(GV, AnnotationString); - auto *Sym = cast<MCSymbolWasm>(getSymbol(F)); + auto *Sym = static_cast<MCSymbolWasm *>(getSymbol(F)); CustomSections[AnnotationString].push_back(Sym); } @@ -618,7 +615,7 @@ void WebAssemblyAsmPrinter::emitFunctionBodyStart() { computeSignatureVTs(F.getFunctionType(), &F, F, TM, ParamVTs, ResultVTs); auto Signature = signatureFromMVTs(OutContext, ResultVTs, ParamVTs); - auto *WasmSym = cast<MCSymbolWasm>(CurrentFnSym); + auto *WasmSym = static_cast<MCSymbolWasm *>(CurrentFnSym); WasmSym->setSignature(Signature); WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp index 4613fcb..e48283a 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp @@ -52,7 +52,7 @@ MCSymbol * WebAssemblyMCInstLower::GetGlobalAddressSymbol(const MachineOperand &MO) const { const GlobalValue *Global = MO.getGlobal(); if (!isa<Function>(Global)) { - auto *WasmSym = cast<MCSymbolWasm>(Printer.getSymbol(Global)); + auto *WasmSym = static_cast<MCSymbolWasm *>(Printer.getSymbol(Global)); // If the symbol doesn't have an explicit WasmSymbolType yet and the // GlobalValue is actually a WebAssembly global, then ensure the symbol is a // WASM_SYMBOL_TYPE_GLOBAL. @@ -123,7 +123,7 @@ MCOperand WebAssemblyMCInstLower::lowerSymbolOperand(const MachineOperand &MO, const MCExpr *Expr = MCSymbolRefExpr::create(Sym, Spec, Ctx); if (MO.getOffset() != 0) { - const auto *WasmSym = cast<MCSymbolWasm>(Sym); + const auto *WasmSym = static_cast<const MCSymbolWasm *>(Sym); if (TargetFlags == WebAssemblyII::MO_GOT) report_fatal_error("GOT symbol references do not support offsets"); if (WasmSym->isFunction()) @@ -148,12 +148,12 @@ MCOperand WebAssemblyMCInstLower::lowerTypeIndexOperand( auto Signature = Ctx.createWasmSignature(); Signature->Returns = std::move(Returns); Signature->Params = std::move(Params); - MCSymbol *Sym = Printer.createTempSymbol("typeindex"); - auto *WasmSym = cast<MCSymbolWasm>(Sym); - WasmSym->setSignature(Signature); - WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); + auto *Sym = + static_cast<MCSymbolWasm *>(Printer.createTempSymbol("typeindex")); + Sym->setSignature(Signature); + Sym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION); const MCExpr *Expr = - MCSymbolRefExpr::create(WasmSym, WebAssembly::S_TYPEINDEX, Ctx); + MCSymbolRefExpr::create(Sym, WebAssembly::S_TYPEINDEX, Ctx); return MCOperand::createExpr(Expr); } diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp index 747ef18..42d1271 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp @@ -104,13 +104,13 @@ const MachineOperand &WebAssembly::getCalleeOp(const MachineInstr &MI) { MCSymbolWasm *WebAssembly::getOrCreateFunctionTableSymbol( MCContext &Ctx, const WebAssemblySubtarget *Subtarget) { StringRef Name = "__indirect_function_table"; - MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol(Name)); + auto *Sym = static_cast<MCSymbolWasm *>(Ctx.lookupSymbol(Name)); if (Sym) { if (!Sym->isFunctionTable()) Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table"); } else { bool is64 = Subtarget && Subtarget->getTargetTriple().isArch64Bit(); - Sym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(Name)); + Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name)); Sym->setFunctionTable(is64); // The default function table is synthesized by the linker. Sym->setUndefined(); @@ -124,12 +124,12 @@ MCSymbolWasm *WebAssembly::getOrCreateFunctionTableSymbol( MCSymbolWasm *WebAssembly::getOrCreateFuncrefCallTableSymbol( MCContext &Ctx, const WebAssemblySubtarget *Subtarget) { StringRef Name = "__funcref_call_table"; - MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol(Name)); + auto *Sym = static_cast<MCSymbolWasm *>(Ctx.lookupSymbol(Name)); if (Sym) { if (!Sym->isFunctionTable()) Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table"); } else { - Sym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(Name)); + Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name)); // Setting Weak ensure only one table is left after linking when multiple // modules define the table. |