diff options
Diffstat (limited to 'llvm/lib/Target/WebAssembly/MCTargetDesc')
5 files changed, 32 insertions, 33 deletions
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp index 890524dd452..80c8db46915 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp @@ -35,7 +35,6 @@ class WebAssemblyAsmBackend final : public MCAsmBackend { public: explicit WebAssemblyAsmBackend(bool Is64Bit) : MCAsmBackend(support::little), Is64Bit(Is64Bit) {} - ~WebAssemblyAsmBackend() override {} unsigned getNumFixupKinds() const override { return WebAssembly::NumTargetFixupKinds; @@ -91,7 +90,7 @@ WebAssemblyAsmBackend::getFixupKindInfo(MCFixupKind Kind) const { bool WebAssemblyAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count) const { - for (uint64_t i = 0; i < Count; ++i) + for (uint64_t I = 0; I < Count; ++I) OS << char(WebAssembly::Nop); return true; @@ -118,8 +117,8 @@ void WebAssemblyAsmBackend::applyFixup(const MCAssembler &Asm, // For each byte of the fragment that the fixup touches, mask in the // bits from the fixup value. - for (unsigned i = 0; i != NumBytes; ++i) - Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff); + for (unsigned I = 0; I != NumBytes; ++I) + Data[Offset + I] |= uint8_t((Value >> (I * 8)) & 0xff); } std::unique_ptr<MCObjectTargetWriter> diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp index 2a3843332a2..8f6531563e1 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp @@ -19,7 +19,7 @@ using namespace llvm; #define DEBUG_TYPE "wasm-mc-asm-info" -WebAssemblyMCAsmInfo::~WebAssemblyMCAsmInfo() {} +WebAssemblyMCAsmInfo::~WebAssemblyMCAsmInfo() = default; // anchor. WebAssemblyMCAsmInfo::WebAssemblyMCAsmInfo(const Triple &T) { CodePointerSize = CalleeSaveStackSlotSize = T.isArch64Bit() ? 8 : 4; diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp index b7bcb7c073f..8d89c568cf9 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp @@ -48,7 +48,7 @@ class WebAssemblyMCCodeEmitter final : public MCCodeEmitter { const MCSubtargetInfo &STI) const override; public: - WebAssemblyMCCodeEmitter(const MCInstrInfo &mcii) : MCII(mcii) {} + WebAssemblyMCCodeEmitter(const MCInstrInfo &MCII) : MCII(MCII) {} }; } // end anonymous namespace @@ -81,14 +81,14 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( encodeULEB128(MI.getNumOperands() - 2, OS); const MCInstrDesc &Desc = MCII.get(MI.getOpcode()); - for (unsigned i = 0, e = MI.getNumOperands(); i < e; ++i) { - const MCOperand &MO = MI.getOperand(i); + for (unsigned I = 0, E = MI.getNumOperands(); I < E; ++I) { + const MCOperand &MO = MI.getOperand(I); if (MO.isReg()) { /* nothing to encode */ } else if (MO.isImm()) { - if (i < Desc.getNumOperands()) { - const MCOperandInfo &Info = Desc.OpInfo[i]; + if (I < Desc.getNumOperands()) { + const MCOperandInfo &Info = Desc.OpInfo[I]; LLVM_DEBUG(dbgs() << "Encoding immediate: type=" << int(Info.OperandType) << "\n"); switch (Info.OperandType) { @@ -126,20 +126,20 @@ void WebAssemblyMCCodeEmitter::encodeInstruction( } } else if (MO.isFPImm()) { - const MCOperandInfo &Info = Desc.OpInfo[i]; + const MCOperandInfo &Info = Desc.OpInfo[I]; if (Info.OperandType == WebAssembly::OPERAND_F32IMM) { // TODO: MC converts all floating point immediate operands to double. // This is fine for numeric values, but may cause NaNs to change bits. - float f = float(MO.getFPImm()); - support::endian::write<float>(OS, f, support::little); + auto F = float(MO.getFPImm()); + support::endian::write<float>(OS, F, support::little); } else { assert(Info.OperandType == WebAssembly::OPERAND_F64IMM); - double d = MO.getFPImm(); - support::endian::write<double>(OS, d, support::little); + double D = MO.getFPImm(); + support::endian::write<double>(OS, D, support::little); } } else if (MO.isExpr()) { - const MCOperandInfo &Info = Desc.OpInfo[i]; + const MCOperandInfo &Info = Desc.OpInfo[I]; llvm::MCFixupKind FixupKind; size_t PaddedSize = 5; switch (Info.OperandType) { diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp index a641ad0ab71..0667816c026 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -39,13 +39,13 @@ static MCAsmInfo *createMCAsmInfo(const MCRegisterInfo & /*MRI*/, } static MCInstrInfo *createMCInstrInfo() { - MCInstrInfo *X = new MCInstrInfo(); + auto *X = new MCInstrInfo(); InitWebAssemblyMCInstrInfo(X); return X; } static MCRegisterInfo *createMCRegisterInfo(const Triple & /*T*/) { - MCRegisterInfo *X = new MCRegisterInfo(); + auto *X = new MCRegisterInfo(); InitWebAssemblyMCRegisterInfo(X, 0); return X; } diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp index d13e1ece9bf..2c97aadd7f9 100644 --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp @@ -43,25 +43,25 @@ WebAssemblyWasmObjectWriter::WebAssemblyWasmObjectWriter(bool Is64Bit) : MCWasmObjectTargetWriter(Is64Bit) {} // Test whether the given expression computes a function address. -static bool IsFunctionExpr(const MCExpr *Expr) { +static bool isFunctionExpr(const MCExpr *Expr) { if (auto SyExp = dyn_cast<MCSymbolRefExpr>(Expr)) return cast<MCSymbolWasm>(SyExp->getSymbol()).isFunction(); if (auto BinOp = dyn_cast<MCBinaryExpr>(Expr)) - return IsFunctionExpr(BinOp->getLHS()) != IsFunctionExpr(BinOp->getRHS()); + return isFunctionExpr(BinOp->getLHS()) != isFunctionExpr(BinOp->getRHS()); if (auto UnOp = dyn_cast<MCUnaryExpr>(Expr)) - return IsFunctionExpr(UnOp->getSubExpr()); + return isFunctionExpr(UnOp->getSubExpr()); return false; } -static bool IsFunctionType(const MCValue &Target) { +static bool isFunctionType(const MCValue &Target) { const MCSymbolRefExpr *RefA = Target.getSymA(); return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_TYPEINDEX; } -static const MCSection *GetFixupSection(const MCExpr *Expr) { +static const MCSection *getFixupSection(const MCExpr *Expr) { if (auto SyExp = dyn_cast<MCSymbolRefExpr>(Expr)) { if (SyExp->getSymbol().isInSection()) return &SyExp->getSymbol().getSection(); @@ -69,23 +69,23 @@ static const MCSection *GetFixupSection(const MCExpr *Expr) { } if (auto BinOp = dyn_cast<MCBinaryExpr>(Expr)) { - auto SectionLHS = GetFixupSection(BinOp->getLHS()); - auto SectionRHS = GetFixupSection(BinOp->getRHS()); + auto SectionLHS = getFixupSection(BinOp->getLHS()); + auto SectionRHS = getFixupSection(BinOp->getRHS()); return SectionLHS == SectionRHS ? nullptr : SectionLHS; } if (auto UnOp = dyn_cast<MCUnaryExpr>(Expr)) - return GetFixupSection(UnOp->getSubExpr()); + return getFixupSection(UnOp->getSubExpr()); return nullptr; } -static bool IsGlobalType(const MCValue &Target) { +static bool isGlobalType(const MCValue &Target) { const MCSymbolRefExpr *RefA = Target.getSymA(); return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_GLOBAL; } -static bool IsEventType(const MCValue &Target) { +static bool isEventType(const MCValue &Target) { const MCSymbolRefExpr *RefA = Target.getSymA(); return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_EVENT; } @@ -94,7 +94,7 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target, const MCFixup &Fixup) const { // WebAssembly functions are not allocated in the data address space. To // resolve a pointer to a function, we must use a special relocation type. - bool IsFunction = IsFunctionExpr(Fixup.getValue()); + bool IsFunction = isFunctionExpr(Fixup.getValue()); switch (unsigned(Fixup.getKind())) { case WebAssembly::fixup_code_sleb128_i32: @@ -104,20 +104,20 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target, case WebAssembly::fixup_code_sleb128_i64: llvm_unreachable("fixup_sleb128_i64 not implemented yet"); case WebAssembly::fixup_code_uleb128_i32: - if (IsGlobalType(Target)) + if (isGlobalType(Target)) return wasm::R_WASM_GLOBAL_INDEX_LEB; - if (IsFunctionType(Target)) + if (isFunctionType(Target)) return wasm::R_WASM_TYPE_INDEX_LEB; if (IsFunction) return wasm::R_WASM_FUNCTION_INDEX_LEB; - if (IsEventType(Target)) + if (isEventType(Target)) return wasm::R_WASM_EVENT_INDEX_LEB; return wasm::R_WASM_MEMORY_ADDR_LEB; case FK_Data_4: if (IsFunction) return wasm::R_WASM_TABLE_INDEX_I32; if (auto Section = static_cast<const MCSectionWasm *>( - GetFixupSection(Fixup.getValue()))) { + getFixupSection(Fixup.getValue()))) { if (Section->getKind().isText()) return wasm::R_WASM_FUNCTION_OFFSET_I32; else if (!Section->isWasmData()) |